Reference · SemText · Prose & code
<sem-code>
SemText element
The code is shown exactly as written — spacing included. You can mark the lines that matter, and the reader gets copy controls a plain code block cannot offer.
Children
-
<pre>Child: the listing — authored flat (the element's own text) or as **at most one `<pre>`**, conventionally wrapping one `<code>`. Flat text with no `<pre>` is adopted into `<pre><code>` at enhance time; a host that already has a `<pre>` child is left as authored. A `<code>` that already holds element children (author-side highlighting) is left as authored — no line spans or `<mark>` are generated over it. More than one `<pre>` child is an error (schema `childRules`). -
<code>Child: the listing — authored flat (the element's own text) or as **at most one `<pre>`**, conventionally wrapping one `<code>`. Flat text with no `<pre>` is adopted into `<pre><code>` at enhance time; a host that already has a `<pre>` child is left as authored. A `<code>` that already holds element children (author-side highlighting) is left as authored — no line spans or `<mark>` are generated over it. More than one `<pre>` child is an error (schema `childRules`). -
<precode>Child: the listing — authored flat (the element's own text) or as **at most one `<pre>`**, conventionally wrapping one `<code>`. Flat text with no `<pre>` is adopted into `<pre><code>` at enhance time; a host that already has a `<pre>` child is left as authored. A `<code>` that already holds element children (author-side highlighting) is left as authored — no line spans or `<mark>` are generated over it. More than one `<pre>` child is an error (schema `childRules`). -
<mark>Child: the listing — authored flat (the element's own text) or as **at most one `<pre>`**, conventionally wrapping one `<code>`. Flat text with no `<pre>` is adopted into `<pre><code>` at enhance time; a host that already has a `<pre>` child is left as authored. A `<code>` that already holds element children (author-side highlighting) is left as authored — no line spans or `<mark>` are generated over it. More than one `<pre>` child is an error (schema `childRules`).
Example
Live render boots with JavaScript — the authored source is alongside.
variant: defaults (no lang, filename or mark)
With `lang`, `filename` and `mark` all unauthored and `controls` left at its default, the chrome bar still renders but carries a single Copy control — nothing is invented. This is the smallest valid listing: the source is the element's own text; the element wraps it in `<pre><code>` when it enhances.
Live render boots with JavaScript — the authored source is alongside.
variant: a line wider than the pane
A single long line with default controls (Copy only). The listing overflows horizontally, so the `<pre>` becomes keyboard-scrollable (`tabindex="0"`, labelled with the filename or `code`). This is the case `controls="copy,wrap"` exists to soften.
Live render boots with JavaScript — the authored source is alongside.
variant: wrap from the start
The `wrap` attribute starts the listing soft-wrapped and the Wrap control renders pressed (`aria-pressed="true"`). Toggling it off removes the attribute and restores horizontal scroll — `wrap` is presentation, never content.
Live render boots with JavaScript — the authored source is alongside.
Source: spec/schema/sem-code.md