ProcessingInstruction (W3C DOM Core object)

Version Depr. Parent
DOM1 No Node
Browser support (more…)
IE5.5+ FF1.5+ SA1.3+ OP9.5+
Buggy Full Full Full


<?xml-stylesheet type="text/xml" href="test.xsl"?>

The example above shows an XSL processing instruction; its target is xsl-stylesheet and its data is type="text/xml" href="test.xsl".


The ProcessingInstruction interface inherits from Node, and represents an XML processing instruction.

A ProcessingInstruction node cannot have children.

Note: A Prolog is not a PI

The XML Prolog at the top of an XML document is not a processing instruction, even though it looks like one.


Internet Explorer Firefox Safari Opera
5.5 6.0 7.0 1.5 2.0 3.0 1.3 2.0 3.0 9.0 9.5
Buggy Buggy Buggy Full Full Full Full Full Full Buggy Full

Internet Explorer and Opera 9.0 treat an XML Prolog as though it were a processing instruction — it appears in the DOM as a ProcessingInstruction node.

: ProcessingInstructions nodes in HTML

Since ProcessingInstruction is an XML construct, it's only reasonable to judge its behavior in terms of XML (either on HTML pages in XHTML mode1, or pure XML). The behavioral variations of browsers in HTML mode2 are documented here for interest and reference, but the support summary table above does not consider this behavior (ie. if the interface works fully in XML then it's considered to be fully supported, with no notes).

Internet Explorer 5.5 in HTML sees processing instructions as Element nodes with the name ! (exactly as it sees comments); consequently it inherits from Node as an Element.

Internet Explorer 6 and 7 in HTML see processing instructions (and XML Prologs) as Comment nodes3.

Firefox in HTML mode and Safari in HTML mode cannot see processing instructions at all.

Opera 9.5 in HTML mode still treats an XML Prolog as a ProcessingInstruction node.

In this Section


1 On XHTML pages served as application/xhtml+xml.

2 On XHTML or HTML pages served as text/html.

3 IE6 ignores the first two characters in the target name (for example, xm in xml-stylesheet), as though they're assumed to have been "--", like a normal comment, even though they weren't. Likewise the last two characters, "? are also missing.

User-contributed notes

There are no comments yet.

Related Products