Firefox Tomorrow

web api instance property

ProcessingInstruction: target property

View on MDN ↗

The read-only target property of the ProcessingInstruction interface represent the application to which the ProcessingInstruction is targeted.

For example:

<?xml version="1.0"?>

is a processing instruction whose target is xml.

Value

A string containing the name of the application.

Example

In an XML document

<output></output>
let parser = new DOMParser();
const doc = parser.parseFromString(
  '<?xml version="1.0"?><test/>',
  "application/xml",
);
const pi = doc.createProcessingInstruction(
  "xml-stylesheet",
  'href="mycss.css" type="text/css"',
);
doc.insertBefore(pi, doc.firstChild);

const output = document.querySelector("output");
output.textContent = `This processing instruction's target is: ${doc.firstChild.target}`;
Interactive exampleOpen the canonical MDN source to run this embedded demo.

In an HTML document

The processing instruction line will be considered, and represented, as a Comment object.

<?xml version="1.0"?>
<pre></pre>
const node = document.querySelector("pre").previousSibling.previousSibling;
const result = `Node with the processing instruction: ${node.nodeName}: ${node.nodeValue}\n`;
document.querySelector("pre").textContent = result;
Interactive exampleOpen the canonical MDN source to run this embedded demo.

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also