I could see if it were like a doctype which changes the way a page is rendered, but what is the point of
xmlns="http://www.w3.org/1999/xhtml"?
| SitePoint Sponsor |
I could see if it were like a doctype which changes the way a page is rendered, but what is the point of
xmlns="http://www.w3.org/1999/xhtml"?


Namespaces are important for identifying which "group" a tag belongs to. Perhaps they're not so important in a lot of cases. But if the XML file has identical tag names used in different contexts they're a must use.

As an example. If you combine XHTML with a second markup language designed to define information about books then both languages would have a <title> tag. You would then need to define which namespace each title tag was in so that the program processing the code would know whether it was a web page title or a book title that a given title tag was referring to.
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">


The point of the XML namespace declaration is that it tells user agents that the document contains XHTML, rather than any other application of XML.
There are two things that are required to make a document be recognised as XHTML:
- The Content-Type HTTP header must declare a MIME type that specifies an application of XML.
- The xmlns attribute must contain the value "http://www.w3.org/1999/xhtml".
The recommended MIME type for XHTML is application/xhtml+xml, but it's also possible to use application/xml or text/xml (although the latter is not recommended).
If either of those conditions are not satisfied, the document is not XHTML.
Birnam wood is come to Dunsinane


Off Topic:
OMG
xmlns='http://www.w3.org/1999/xhtml'
10 years already!
Bookmarks