Take the 2-minute tour ×

If I have a xhtml document, I assume the default namespace is "xhtml". Is there any advantage, or disadvantage, to explicitly declaring this default namespace, as in:

  <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude">

  . . .
share|improve this question

1 Answer 1

up vote 2 down vote accepted

In HTML5 compatible browsers the default namespace for HTML elements in the HTML serialization is http://www.w3.org/1999/xhtml

In the XHTML serialization, XML rules apply. If you don't assign a default namespace using xmlns=, unprefixed elements will be in no namespace, and the browser will not understand how to interpret your markup. In that sense, you need to explicitly declare the default namespace.


Whether you are using the HTML serialization or the XHTML serialization depends not on the DOCTYPE but on the content-type. You only get the XHTML serialization if you serve the page with an XML content type such as application/xhtml+xml.

If you serve the page with a content type of text/html (and I'm willing to bet you are, since almost everybody does) then you are using the HTML serialization and your XHTML 1.0 Strict doctype is of no consequence. In that case, the default namespace declaration is achieving nothing except keeping the validator quiet.

share|improve this answer
Does this mean that the browsers will still successfully render the html elements even if they happen to not belong to a namespace? –  chad Nov 14 '11 at 14:30
No, it means they must always be in the http://www.w3.org/1999/xhtml namespace to be rendered correctly. But in HTML, this happens "magically". –  Alohci Nov 14 '11 at 18:19

Your Answer


