Processing instruction

A processing instruction extends an HTML or XML element with an instruction targeting a specific application, which can be ignored by any application that doesn't recognize the instruction.

Processing instructions start with <? and end with ?> (although, in HTML only, they may also end with just >), contain a target (or name) and may contain one or more attributes in between. In non-supporting browsers, processing instructions will be interpreted as comments and represented as Comment objects in the DOM tree.

XML example

In XML you can include a stylesheet to explain how to render the XML:

xml
<?xml-stylesheet href="styles.css"?>

HTML example

In HTML, processing instructions were introduced to allow patching using <template for>:

xml
<body>
  <div>
    <?start name="placeholder">
    Loading...
    <?end>
  </div>
  ...
  <template for="placeholder">
    Lorem Ipsum...
  </template>
  ...
</body>

Note that processing instructions do not create nesting since they are flat, as indicated by the fact that Loading... is not indented in the previous example.

See also