I have a doctype declaration as seen in the first 2 lines.
In the third line, the html tag also has some xmlns declaration and xml:lang and lang. Is any of these xmlns, xml:lang, or lang repetitive? Do they duplicate anything from the doctype. I’d like to keep the doctype and remove all the declarations on the third line if they’re repetitive.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
</html>
They’re not repetitive. The XML namespace for XHTML and the doctype declaration aren’t the same. Neither are the
xml:langandlangattributes. The XHTML 1.0 specification requires that all of these are included.The attribute list for the
<html>element as described by the XHTML 1.0 Strict DTD is as follows:(where
%i18nis an internal entity that represents thexml:lang,langanddirinternationalization attributes, see below)Notice the fourth line. It says that
xmlnsis an attribute of a given URI value, and is fixed at that very namespace URL. That means if you omit the attribute or give it a different namespace, your document is invalid strict XHTML.The
%i18nentity corresponds to these attributes:The
langattribute is for backwards compatibility (i.e. HTML ≤ 4.01), andxml:langis described by XML 1.0 (hence thexmlnamespace seen here). I’m not too sure of the exact reason whyxml:langshould precedelang, but it makes sense given that XHTML is merely HTML “reworded” into XML syntax (so to speak).The
dirattribute defaults toltr(left-to-right text) if not specified, hence it’s not a required attribute.