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.

The xml Declaration

The xml declaration in HTML 5

The xml declaration is the first line of code and indicates that the content is a HTML document.

Converting to HTML 5

We are working on converting to HTML 5. Please visit XML Declaration for HTML on the HTML 5 standard version of this site.

<?xml?> Declaration Syntax

Syntax of the <?xml?> declaration

Attributes of the xml Declaration

Attributes of the xml declaration

version attribute
The version attribute is coded as version="1.0", which indicates the document follows the XML version 1.0 syntax. The document should be coded to be "well-formed", even if it is not an entirely "valid" HTML document.
encoding attribute
The encoding attribute indicates what character encoding has been used to encode the HTML document as a file or byte input stream. Most importantly, among other things, this determines how many bytes of raw data are consumed to compose each character of the decoded document.
HTML 5 Examples

Examples of the xml declaration in HTML 5

The xml declaration appears at the very beginning of an HTML document:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/site-template.xsl"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
...
</html>

It is recommended that the encoding be specified using the preferred (MIME) name as specified in the IANA 's Official Names for Character Sets. Some examples:

<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml version="1.0" encoding="US-ASCII"?>
<?xml version="1.0" encoding="EUC-JP"?>
<?xml version="1.0" encoding="UTF-16"?>
<?xml version="1.0" encoding="ISO-10646-UCS-2"?>
<?xml version="1.0" encoding="ISO-10646-UCS-4"?>
Changes in HTML 5

What's new in HTML 5

Differences between HTML 5 and earlier versions

The xml declaration does not appear in HTML documents conforming to the 1997 HTML version 4 standard. For 2000 and later XHTML 1.x documents, the xml declaration was optional. For HTML version 5 documents, it's use is highly recommended.

Last updated Sunday September 19, 2010


Printer-friendly PDF* format:

xml Declaration

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.