http://www.w3.org/1999/xhtml and other HTML Namespaces

Namespaces in HTML 5

Converting to HTML 5

We are working on converting to HTML 5. Please visit http://www.w3.org/1999/xhtml and other HTML Namespaces on the HTML 5 standard version of this site.

Commonly used namespaces in HTML include:

http://www.w3.org/XML/1998/namespace
the XML namespace; implicitly declared
http://www.w3.org/2000/xmlns/
the namespace for XML namespaces; also implicitly declared
http://www.w3.org/1999/xhtml
the HTML namespace, the same one already being used for XHTML
http://www.w3.org/1998/Math/MathML
the MathML namespace
http://www.w3.org/2000/svg
the SVG namespace
the XLink namespace
http://www.w3.org/2001/XMLSchema-instance
the namespace for XML Schema instance documents, which can be used to specify whether the data for a field is binary (possibly encrypted) or plain text: <span id="masked-credit-card-number" xsi:type="xsd:string">4321 **** **** 8765</span>
<span id="encrypted-credit-card-number" xsi:type="xsd:base64Binary">BAM0NComFzC2TOsmRzW0NTueQU==</span>
http://www.w3.org/1999/XSL/Transform
the namespace for XSL style sheets, not used in HTML documents themselves, but used in the style sheet documents referenced by the xml-stylesheet instruction.

Namespace Declarations in <html> Tag

The easiest way to declare namespaces is by putting the xmlns attributes in the top element of the XML document, which in this case is the <html> tag: <html xmlns="http://www.w3.org/1999/xhtml"
xmlns:mathml="http://www.w3.org/1998/Math/MathML"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
In HTML 5, all elements (tags) are automatically considered to be qualified with the HTML 5 namespace, which makes the declaration of the HTML namespace optional, but this only works when the HTML parser supports HTML 5 and is actually looking at the page as an HTML version 5 document. It's best to continue coding the xmlns="http://www.w3.org/1999/xhtml" explicitly to provide backward compatibility with non-HTML5-aware browsers and other types of programs that may be parsing the HTML, such as RSS feed readers - otherwise all of the HTML tags will appear to be in the unnamespaced partition.

Next: Sections 

Home > Namespaces

Viewing mobile website page. Switch to WML or Full HTML