← Chrome 148 reference

v148 · html · behind a flag

Parse processing instructions in HTML

Limited availability

  • Chrome · 150 (148 behind a flag)
  • Edge · 150
  • Firefox · not shipped
  • Safari · not shipped

Not Baseline. webstatus.dev reports the html-processing-instructions web feature as limited availability (API record, queried 2026-11-15): Chrome and Chrome Android 150 (2026-06-30), Edge 150 (2026-07-02), no Firefox or Safari implementation. The ProcessingInstruction interface itself (XML documents, target, data) has worked in every engine for decades. See the full table.

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.

Behind a flag in Chrome 148 — not an origin trial Correction (2026-11-15): earlier revisions of this page called this an origin trial. ChromeStatus records no origin trial: its experiment intent is described as “a finch (to 1% stable) rather than an OT”, and the feature ships enabled by default in Chrome 150 (intent to ship). It appears in the milestone-150 listing, not the milestone-148 listing (queried 2026-11-15); the shipped reference is v150/parse-processing-instructions-in-html. In Chromium 148 the parser change and the attribute methods sit behind 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

AvailabilityChrome 148 behind a flag (M148 runtime flags; not in the milestone 148 listing); enabled by default in Chrome 150 (milestone 150 listing)
StatusFlag HTMLProcessingInstruction (experimental) in 148; 1% stable Finch experiment, not an origin trial (experiment intent); shipped in 150
Standards positionSafari: Support (WebKit/standards-positions#628)  ·  Firefox: Positive (mozilla/standards-positions#1369)
SpecHTML Standard §13.1.7 Processing instructions (now in the Living Standard; from whatwg/html PR #12118); DOM Standard §4.13 ProcessingInstruction
Blink componentBlink>HTML>Parser
ChromeStatus6534495085920256 — Parse processing instructions in HTML (API record)
IssueChromium 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:

Source: chromestatus summary and whatwg/html PR #12118.

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 (>).

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.

MemberReturnsBehaviour / errors
getAttribute(name)DOMString?Value from the attribute map, or null.
hasAttribute(name)booleanWhether the map has name.
hasAttributes()booleanFalse if the map is empty.
getAttributeNames()sequence<DOMString>The map’s keys (no duplicates).
setAttribute(name, value)undefinedThrows InvalidCharacterError if name is not a valid attribute local name; otherwise sets it and rewrites data.
removeAttribute(name)undefinedNo-op if absent; otherwise removes it and rewrites data.
toggleAttribute(name [, force])booleanThrows InvalidCharacterError for an invalid name; adds (empty value) or removes per force; returns whether name is now present.
new ProcessingInstruction(target, data)nodeSpec 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.targetThe PI target string (e.g. "start")
ProcessingInstruction.dataThe data portion after the target (e.g. "section-1")
Node.nodeType7 (Node.PROCESSING_INSTRUCTION_NODE)
Node.parentNodeThe containing element or document node
Source: DOM Standard §4.13 ProcessingInstruction; HTML Standard §13.1.7; Chromium M148 processing_instruction.idl. Read 2026-11-15.

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&lt;b"
marker.toggleAttribute('hidden');       // true; data is now: name="a&lt;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.

Live example from the Chrome Platform Showcase (route checked 200, 2026-11-15). Other concepts: range marker highlighter, PI query explorer, annotation stream, PI annotation system.Source: chrome-platform-showcase

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 support for HTML-parsed processing instructions and the attribute methods
BrowserHTML parsing + attribute methodstarget / data (XML)Notes
Chrome1501148: behind HTMLProcessingInstruction (M148 runtime flags); BCD does not record the flag.
Edge15012BCD "edge": "mirror"; webstatus.dev records Edge 150 (2026-07-02).
FirefoxNot supported1BCD version_added: false. Position: Positive (mozilla/standards-positions#1369).
SafariNot supported1BCD version_added: false. Position: Support (WebKit/standards-positions#628).
Source: BCD api/ProcessingInstruction.json; webstatus.dev html-processing-instructions; chromestatus browser views.

specifications

Source: HTML Living Standard and DOM Living Standard, read 2026-11-15.

see also