PDA

View Full Version : XHTML 1.0 Strict Doctype Declaration



Stewart
8th Oct 2009, 12:11 am
Noticed on the W3C site that the doctype declaration that they appeared to define for XHTML 1.0 strict was:-

<!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">

which seemed to differ a little from the one we discussed today which ended in dir="ltr" lang="en"

Was wondering why and which way to go ?

David
8th Oct 2009, 09:52 am
There is an explanation of these attributes here (http://www.w3schools.com/TAGS/tag_html.asp). As far as I can tell, the "lang" attribute is a generic language identifier whereas "xml:lang" is specific to XHTML. I'm not sure, therefore, why both need to be included. The bottom line is that for XHTML documents, only the "xmlns" attribute is required, the other attributes are optional. So, as long as you have at least this:



<!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">


Your code will validate.

David
8th Oct 2009, 10:16 am
Further to the above, the "lang" attribute is the HTML4 version of XHTML's "xml:lang" and it may be that both are specified in XHTML documents for backwards compatibility (i.e. for older browsers). Here's a typical W3C take (http://www.w3.org/TR/2002/REC-xhtml1-20020801/#C_7) on it.

philipjcowan
11th Oct 2009, 11:35 pm
I had a little trouble with validating the doctype header thingymajig but found setting the validator in W3C to auto detect ironed it out.

You know me, if it works......

Philip