You are currently using a web browser that does not support HTML 5 with style sheets. Please try the standard HTML 5, XHTML 1 or XHTML 1 Mobile version of this page instead.

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.

Last updated Sunday June 20, 2010


Printer-friendly PDF* format:

HTML 5 Tutorial

You are currently viewing this page in HTML 5 Style Sheet* format (* see Clicklets for more infomation). This document is also available in HTML 5 XML*HTML 5 non-XML*XHTML 1 Style Sheet*XHTML 1*XML* HTML 4* XHTML Mobile* WML Mobile* and printer-friendly PDF* formats. This is accomplished with Single Source Publishing, a content management system that uses templates in XSLT style sheets provided by XML Styles .com to transform the source content for various content delivery channels. There is also RDF* metadata that describes the content of this document.