v148 · html · behind a flag
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.
HTMLProcessingInstruction, marked experimental in runtime_enabled_features.json5 (branch 7778). To try it in Chrome 148, enable chrome://flags/#enable-experimental-web-platform-features or launch with --enable-blink-features=HTMLProcessingInstruction. Without it, <?…> in HTML is still turned into a comment.
at a glance
| Availability | Chrome 148 behind a flag (M148 runtime flags; not in the milestone 148 listing); enabled by default in Chrome 150 (milestone 150 listing) |
|---|---|
| Status | Flag HTMLProcessingInstruction (experimental) in 148; 1% stable Finch experiment, not an origin trial (experiment intent); shipped in 150 |
| Standards position | Safari: Support (WebKit/standards-positions#628) · Firefox: Positive (mozilla/standards-positions#1369) |
| Spec | HTML Standard §13.1.7 Processing instructions (now in the Living Standard; from whatwg/html PR #12118); DOM Standard §4.13 ProcessingInstruction |
| Blink component | Blink>HTML>Parser |
| ChromeStatus | 6534495085920256 — Parse processing instructions in HTML (API record) |
| Issue | Chromium issue 481087638 |
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
Formal syntax (HTML)
Verbatim from HTML Standard §13.1.7. Processing instructions must have the following format:
1. "<?".
2. A target.
3. Either of the following two options:
- Zero or more ASCII whitespace.
- One or more ASCII whitespace, followed by data.
4. Optionally, a U+003F (?).
5. A U+003E (>).
- target: ASCII alphanumerics,
-and_; must start with an ASCII alpha or_, and must not be an ASCII case-insensitive match forxmlorxml-stylesheet. - data: text that must not contain
>nor end with?. - Differences from XML: in HTML a PI can end with
>or?>;<?xml …?>and<?xml-stylesheet …?>stay bogus comments for compatibility; only this restricted target subset is allowed, not XML’s fullNameproduction.
The parser creates a ProcessingInstruction node with .target and .data properties.
DOM interface (formal syntax)
Verbatim from DOM Standard §4.13. The attribute methods are what this feature adds; Chromium 148’s processing_instruction.idl declares all seven under RuntimeEnabled=HTMLProcessingInstruction but has no constructor.
[Exposed=Window]
interface ProcessingInstruction : CharacterData {
constructor(DOMString target, optional DOMString data = "");
readonly attribute DOMString target;
boolean hasAttributes();
sequence<DOMString> getAttributeNames();
DOMString? getAttribute(DOMString name);
undefined setAttribute(DOMString name, DOMString value);
undefined removeAttribute(DOMString name);
boolean toggleAttribute(DOMString name, optional boolean force);
boolean hasAttribute(DOMString name);
};
Attribute map. Each PI has an attribute map parsed from its data with the “rules for parsing pseudo-attributes” (name="value" pairs). Changing data re-parses the map; if the data does not parse as pseudo-attributes the map is simply empty. Every attribute mutation rewrites data as name="value" pairs separated by spaces, with &, <, > and " escaped as entities.
| Member | Returns | Behaviour / errors |
|---|---|---|
getAttribute(name) | DOMString? | Value from the attribute map, or null. |
hasAttribute(name) | boolean | Whether the map has name. |
hasAttributes() | boolean | False if the map is empty. |
getAttributeNames() | sequence<DOMString> | The map’s keys (no duplicates). |
setAttribute(name, value) | undefined | Throws InvalidCharacterError if name is not a valid attribute local name; otherwise sets it and rewrites data. |
removeAttribute(name) | undefined | No-op if absent; otherwise removes it and rewrites data. |
toggleAttribute(name [, force]) | boolean | Throws InvalidCharacterError for an invalid name; adds (empty value) or removes per force; returns whether name is now present. |
new ProcessingInstruction(target, data) | node | Spec only (absent from Chromium 148 IDL and from BCD). Throws InvalidCharacterError if target is not an XML Name or data contains ?>. |
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
Processing instructions can be placed directly in HTML documents and queried using standard DOM tree traversal:
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?>
Reading and writing pseudo-attributes
// HTML: <div><?start name="results">Loading…<?end></div>
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_PROCESSING_INSTRUCTION);
for (let pi = walker.nextNode(); pi; pi = walker.nextNode()) {
if (!('getAttribute' in pi)) break; // feature-detect (Chrome 150+, or 148 with the flag)
console.log(pi.target, pi.getAttribute('name')); // "start" "results", then "end" null
}
const marker = document.createProcessingInstruction('marker', '');
marker.setAttribute('name', 'a<b');
console.log(marker.data); // name="a<b"
marker.toggleAttribute('hidden'); // true; data is now: name="a<b" hidden=""
marker.setAttribute('bad name', 'x'); // throws InvalidCharacterError
Source: method steps and data serialisation from DOM Standard §4.13.
Live demo
All five interactive demos are on the chrome-platform-showcase feature page. The embed below is the PI tree inspector concept; in Chrome 148 it needs the flag above.
browser compatibility
Per-version data from BCD api/ProcessingInstruction.json (fetched raw 2026-11-15). doc_html is “processing instructions parsed in HTML documents”; the seven attribute methods share its row. BCD has no entry for the constructor.
| Browser | HTML parsing + attribute methods | target / data (XML) | Notes |
|---|---|---|---|
| Chrome | 150 | 1 | 148: behind HTMLProcessingInstruction (M148 runtime flags); BCD does not record the flag. |
| Edge | 150 | 12 | BCD "edge": "mirror"; webstatus.dev records Edge 150 (2026-07-02). |
| Firefox | Not supported | 1 | BCD version_added: false. Position: Positive (mozilla/standards-positions#1369). |
| Safari | Not supported | 1 | BCD version_added: false. Position: Support (WebKit/standards-positions#628). |
specifications
| Specification | Status |
|---|---|
| HTML Standard §13.1.7 — processing instructions | Living Standard (from whatwg/html PR #12118) |
| DOM Standard §4.13 — interface ProcessingInstruction | Living Standard |
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