Skip to main content

Styling

Style is written on the element it affects. There are no stylesheets, no selectors, no class names and therefore no cascade. An element's appearance depends on that element, the document's defaults, and nothing else.

<p color="navy" letter-spacing={0.5} align="center">…</p>
<p color="rgb(255 0 128 / 50%)">…</p>
<page size="A4" flow>…</page>

Where a value comes from​

Three sources, one level deep:

  1. what the tag states;
  2. a default keyed by tag name in the project file (element.h1);
  3. the engine's fixed value.

Exactly one origin per property. That is what makes “no unexplained layout” checkable. A property stated twice on one element is not resolved by specificity — there is no second rule to compare against.

{
"element": {
"p": { "font-size": 9.5, "leading": 1.35, "align": "justify" },
"h1": { "font-size": 18, "leading": 1.1 },
"caption": { "font-size": 8, "leading": 1.25 }
}
}

A tag's own attribute beats the project default. Nothing inherits from a container: a <col> cannot set a font size for its children.

Value forms​

WrittenMeaning
name="text"A string literal
name={expression}An expression: number, bool, identifier, object or array
nameBoolean true
name={…} />A self-closing element

Strings use double quotes. Expressions are the small expression language from Components; there is no arithmetic.

Properties by tag​

Text blocks — p, h1–h6, caption​

PropertyValue
font-sizePoints (ignores unit)
leadingA multiple of the font size
alignleft, center/centre, right, justify
colorAny sRGB colour
font-familyA declared family
font-weightnormal, bold, or 1–1000
font-stylenormal, italic, oblique
letter-spacingPoints, or a string such as "0.08em"
indentLength; first line
hangingLength; later lines
space-beforeLength above the block
unitUnit for this tag's lengths
idLink target

Inline — span​

font-size, color, letter-spacing, font-family, font-weight, font-style, offset (a length), unit.

Page — page​

size, width, height, unit, margin, binding, flow, id.

Image — img​

src, width, alt, id, unit.

Table — table, cell, rule​

TagProperties
tablecolumns, align (array), id
cellheader, span, rows, align
ruleheight, width, column, color, from, to

Containers and structure​

TagProperties
col, div, section, body, bibgap, keep, id
rowgap, keep; children take width or weight
columnscount, gap, unit
floatplacement, cols
ato or href
footnotelabel
doc, head, title, metaMetadata; see Documents

An unrecognized property on a tag is not silently applied. Unknown block or inline tags are reported (unknown-block, inline-element) and their content is kept.

Lengths and units​

  • A length on a tag uses that tag's unit; nothing inherits it.
  • The default unit is millimetres.
  • Units: mm, cm, in, pt, pc, px (0.75 pt).
  • Typographic sizes — font-size, numeric letter-spacing — are always points and ignore unit.
  • leading is a ratio, so it carries no unit and no suffix.
<p unit="pt" indent={12}>Twelve points, not twelve millimetres.</p>

Coupled values​

Some pairs are alternatives, and stating both is an error rather than a precedence rule:

PairRule
indent, hangingOne or the other, never both (indent-hanging)
size, width/height on a pagesize wins; an explicit size plus dimensions is not combined
to, href on a linkto wins if both are present

Colour​

Named colours, #rgb, #rrggbb, #rrggbbaa, and rgb() with optional alpha:

color="navy"
color="#b23a24"
color="#b23a2480"
color="rgb(178 58 36 / 60%)"

Names: black, white, red, green, blue, navy, gray/grey, silver, maroon, olive, teal, purple.

Sharing a style​

A style that can be written as an object is a value:

export const tight: CellStyle = { font-size: 8, leading: 1.2 };
<DataTable config={tight} />

A project styles a hundred tables from one declaration, and a component carries the appearance of what it generates, so a call site says what and not how.

A shared value costs only the value. There is no rule, no selector, and no indirection through a name that must still be typed everywhere.

Deliberately absent​

  • stylesheets and rules;
  • selectors, classes and ids used for styling;
  • cascade and inheritance from containers;
  • author-invented names for a look;
  • synthetic bold or italic;
  • small caps as a switch (use a face).

The id attribute is inert: it exists for links and numbering, never for styling.