CKTIS / HTML
HTML concept: content-categories
Content categories classify HTML elements, while the parent content model and element-specific restrictions decide whether a particular nesting is conforming.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
category membership + the parent content model + element-specific restrictionsAn element can belong to several groups at once, such as flow content, phrasing content, conditionally interactive content, or palpable content. Membership describes element characteristics and can depend on attributes; it is not one list of permitted children.
A parent model is a separate constraint: p accepts phrasing content, so div does not become allowed merely because both are flow content. The a element belongs to both flow and phrasing content; it additionally belongs to interactive content only when it has href, and its transparent model forbids interactive descendants.
A transparent model passes through the requirements of the position where the element occurs: children of a, ins, or map must satisfy the nearest nontransparent context. With nesting, resolution is iterative, and the result is the intersection of inherited requirements and every element’s own prohibitions.
The example parses a div inside a transparent a placed in a p with DOMParser. Because the paragraph accepts only phrasing content, the parser closes it before the block and reconstructs the link; the DOM has the block under body and two link elements. That is parser repair, not proof that the source conforms.
Examples
<!doctype html>
<meta charset="utf-8">
<output id="result"></output>
<script>
const source = "<p id=outer><a href=#><span>ok</span><div id=block>block</div></a>tail</p>";
const parsed = new DOMParser().parseFromString(source, "text/html");
const outer = parsed.querySelector("#outer");
const block = parsed.querySelector("#block");
result.textContent = `outer=${outer.textContent}; blockParent=${block.parentElement.localName}; outerHasBlock=${outer.contains(block)}; links=${parsed.querySelectorAll("a").length}`;
</script>
Result
outer=ok; blockParent=body; outerHasBlock=false; links=2
The executed example verifies the phrasing-model boundary and tree repair; validation must still examine category membership, the parent model, and transparent restrictions.