Forum Moderators: open
<?xml version="1.0?>
<!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">
But, I've heard that that first line can make the page explode in old browsers. And I've also found that the w3c validator will still say the page is valid if I start it like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
So, is it okay to use this second option, or should I really be using the first option?
The XML prolog can be used to define the charset of the document: however, it is usually better practice to define this in the HTTP header instead. The prolog only becomes truly relevant when you are serving your document with the mime type
application/xhtml+xml and you are strictly following the standards.
xmlns attribute is for the XML namespace: it is usually present in conforming XHTML documents. It is not vital unless, again, you are serving application/xhtml+xml and perhaps mixing different namespaces. I would leave it in. The
xml:lang and lang attributes are the XML method and HTML method respectively for declaring the document language (in your example, English). It is good practice to always declare the language in this way.