XML Attributes in HTML

 

ATTENTION: THIS PAGE IS Valid HTML 5 AND IS BEST VIEWED WITH HTML 5 - Please upgrade your browser or download one of the HTML 5 compatible browsers such as Mozilla Firefox, Chrome, Opera or IE 9 (March 14, 2011 or later). For more information see HTML 5 browsers.


If you find this helpful, please click the Google +1 Button to the left, if it is white, to make it turn blue or red. Thank you! (It also helps find this page again more easily.)


PDF mobile

xmlns attribute in HTML

The xmlns attribute for declaring the default namespace is a reserved attribute and not classified as either a global attribute or local attribute. Although it can be specified on any HTML element, best practices suggest to declare the namespace for the entire document on the <html> top element where it will be inherited by all of its descendants.

When the document is being parsed as HTML, the xmlns attribute is ignored, since all HTML elements are automatically assigned to the HTML namespace and the name of the xmlns attribute itself is allocated in the namespace partition with no namespace URI, along with the names of other global attributes.

When the document is being parsed as XML, the xmlns attribute name is allocated in the http://www.w3.org/2000/xmlns/ namespace, separate from the HTML global attributes in the HTML namespace.


xml:lang attribute in HTML

The xml:lang attribute may be included for use when the document is being parsed as xHTML, the XHTML-compatible serialization of HTML, or as pure XML. When it is coded, the lang global attribute must also be coded with the same value.

In documents that are being parsed as HTML rather than xHTML or pure XML, the xml:lang attribute is considered to be a non-XML-namespace attribute with the local name "xml:lang".


xml:space attribute in HTML

In documents being parsed as XML, the parser's handling of white space can be controlled to some extent by specifying a value for the xml:space attribute as in:

xml:space="default"
indicates that the default mode of handling white space should be used for the element and its decendants
xml:space="preserve"
indicates that all white space that is coded in the document should be included in the data that is passed from the parser to the application

Since the default behavior for HTML elements is to preserve white space, both values have the same effect and so the xml:space attribute can simply be omitted.


Valid HTML 5