v148 · html · origin trial
Parse processing instructions in HTML
Chrome 148 teaches the HTML parser to recognise processing instructions — the <?target data?> syntax already used in XML and SVG — and expose them as ProcessingInstruction nodes in the DOM. Parsers and streaming frameworks can use them as lightweight range markers or directives without touching element structure.
at a glance
| Origin trial | Chrome 148+ |
|---|---|
| Status | Origin trial (Experiment) |
| Standards position | Safari: Support · Firefox: No signal |
| Spec | whatwg/html PR #12118 (Working draft) |
| Blink component | Blink>HTML>Parser |
| ChromeStatus | 6534495085920256 — Parse processing instructions in HTML |
why it exists
Processing instructions (PIs) are an established DOM primitive in XML: they appear as ProcessingInstruction nodes and carry an arbitrary target and data string that tooling can act on while leaving element structure untouched. Until this feature, the HTML parser silently discarded PIs. The motivation is to enable two new use-cases without adding new element types that would affect CSS layout:
- Range markers —
<?start id?>/<?end id?>pairs delimit DOM regions (used by out-of-order streaming and syntax-highlighting tools). - Parser directives — targets can signal to a streaming parser how to buffer or flush content.
syntax
A processing instruction in HTML markup follows the XML grammar:
<?target data?>
where target is a name token and data is an arbitrary string that does not contain ?>. The parser creates a ProcessingInstruction node with .target and .data properties.
DOM interface (existing)
| ProcessingInstruction.target | The PI target string (e.g. "start") |
|---|---|
| ProcessingInstruction.data | The data portion after the target (e.g. "section-1") |
| Node.nodeType | 7 (Node.PROCESSING_INSTRUCTION_NODE) |
| Node.parentNode | The containing element or document node |
example
Inserting a PI in HTML and reading it from JS
<!-- HTML source -->
<div>
<?highlight start="1" end="3"?>
<p>Line one</p>
<p>Line two</p>
<p>Line three</p>
<?highlight end?>
</div>
<script>
// Walk childNodes and collect PIs
const pis = [];
document.body.querySelectorAll('*').forEach(el => {
for (const child of el.childNodes) {
if (child.nodeType === Node.PROCESSING_INSTRUCTION_NODE) {
pis.push({ target: child.target, data: child.data });
}
}
});
console.log(pis);
// [{ target: "highlight", data: "start=\"1\" end=\"3\"" },
// { target: "highlight", data: "end" }]
</script>
Using createProcessingInstruction from JS
const pi = document.createProcessingInstruction('stream', 'flush-before');
document.body.prepend(pi);
// <?stream flush-before?>
browser support
| Chrome | 148 (desktop) |
|---|---|
| Edge | 148 (Chromium) |
| Firefox | No signal |
| Safari | Support (date TBD) |
see also
- whatwg/html PR #12118 — spec pull request
- DOM Standard: ProcessingInstruction
- Out of order streaming — related feature using PI range markers
- chromestatus: Parse processing instructions in HTML
- chrome-platform-showcase: demos