Helpful Information
 
 
Category: Programming Languages More
Xhtml - <html xmlns=...> question.

Hi,

I am updating my HTML to the xhtml 1.0 specification to make any updates later involving XML easier. At the moment my <html> tag looks like:

<html xml:lang="en" lang="en">

But I see that some people add the following:

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

Is it needed, and what does it do? I want to keep everything to specification and know what everything in the file does. Thanks for your help!

It declares the main namespace. If you were to save your document as .xml instead of .html, and expected it to render as XHTML, you would need the xmlns="bla" declaration inside the root element.

Slight clarification of what jkd explained: regardless of what extension you save the file with, to be an XHTML conforming document the xmlns attribute must be "present" with that value. Actually, the attribute is declared with a fixed value in the DTD, so if you don't specify it in your document it will still be valid. If you do specify it, it must have that value. See XHTML 1.0: The Extensible HyperText Markup Language: 3.1.1 Strictly Conforming Documents (http://www.w3.org/TR/xhtml1/#docconf).