Styling
Every surface loads with a host-provided stylesheet that exposes the terminal's colors, font, and cell dimensions (§8). Documents styled with these defaults integrate visually with the terminal and adapt automatically when the user changes themes. Any CSS rule in your document overrides the host stylesheet.
The host stylesheet
Host rules have lower cascade priority than author rules (like a browser's user-agent stylesheet), establishing defaults that your CSS can override. On the root element, the host sets:
| property | value |
|---|---|
color, background |
the terminal's foreground and background colors |
font-family, font-size |
the terminal's font family and size |
line-height |
one cell's height (making 1rlh equal to one terminal row) |
color-scheme |
the terminal's scheme (dark or light) |
accent-color |
the terminal's blue accent color |
overflow |
hidden (nothing scrolls unless the document opts in; see Surfaces) |
body has zero margin. The stylesheet also defines custom properties for use in
your own CSS:
| property | value |
|---|---|
--hotty-fg, --hotty-bg |
the terminal's foreground and background colors |
--hotty-ansi-0 … --hotty-ansi-15 |
the 16 ANSI colors of the terminal's active theme |
--hotty-accent |
the terminal's blue (ansi-12 in dark themes, ansi-4 in light themes) |
--hotty-font |
the terminal's font family, falling back to monospace |
--hotty-cell-w, --hotty-cell-h |
cell width and height in CSS pixels |
--hotty-px |
one device pixel in CSS pixels |
The --hotty- custom property prefix and data-hotty- attribute prefix are
reserved by the protocol. Use different prefixes for your own properties and
attributes.
The palette
The 16 ANSI colors are guaranteed to be tuned for contrast in every terminal theme (Appendix B). Styling with these variables ensures your UI remains legible across any theme the user chooses:
.ok { color: var(--hotty-ansi-2); } /* green */
.fail { color: var(--hotty-ansi-1); } /* red */
.muted { color: var(--hotty-ansi-8); } /* bright black, for secondary text */
.card { border: 1px solid var(--hotty-ansi-8);
background: color-mix(in srgb, var(--hotty-bg) 85%, var(--hotty-accent)); }
Built-in form controls—text fields, buttons, checkboxes, focus rings, links, and
text selection—also use the terminal palette rather than the rendering engine's
native defaults, ensuring consistent appearance across hosts. ansi-8 is used
for borders, button surfaces, placeholders, and disabled states.
Default focus rings apply only to interactive controls: links, buttons, text
fields, contenteditable elements, <select>, and <summary> (new in 0.6).
Generic focusable containers—such as a <ul tabindex=0> handling keybindings or
a scrollable <article>—do not show a focus ring by default. Add one explicitly
if needed:
ul[tabindex]:focus-visible { outline: 1px solid var(--hotty-accent); }
As with all host defaults, author styles override control styling.
Light and dark
The host reports whether the terminal theme is dark or light via the
scheme capability (§4). The host
stylesheet sets color-scheme to match, and @media (prefers-color-scheme)
reflects it, so you can define custom light and dark colors when the ANSI
palette is not enough:
:root { --line: #3c9; }
@media (prefers-color-scheme: light) { :root { --line: #075; } }
When the terminal theme changes, the host updates the stylesheet and repaints
all surfaces automatically—documents using the palette adapt with no protocol
traffic. The host emits a caps event only if scheme itself flips between
dark and light.
The device
@media (pointer: coarse), (hover: none), and their any- forms match the
device the host draws on, as in a browser: a phone is coarse with no hover, a
desktop fine with hover. Use them to give touch bigger targets; your program
hears nothing of them (Pointers and touch).
Sizes in cells
--hotty-cell-w and --hotty-cell-h expose the size of a single terminal cell
in CSS pixels (matching cellcss in capabilities). Use them to align layout
dimensions with the terminal grid:
.label { width: calc(12 * var(--hotty-cell-w)); }
.rows { display: grid; gap: 1rlh; } /* the root's line-height is one row */
A surface's viewport is its placed size (c by r cells)
(§5.3). Media queries and viewport units (vw,
vh) evaluate against that viewport, allowing responsive layouts within the
placed region.
When the terminal font changes, cell dimensions in CSS pixels change as well,
and on some hosts so can moving the window to a display of another density.
The host reflows all surfaces with updated --hotty-cell-* values and emits
caps with the new cellcss. Placements keep their cell dimensions, and
placements with f=1 emit fit if the reflow changed their required row count
(Surfaces).
Fonts
The root inherits the terminal's font and size, and --hotty-font provides the
font family name. You can switch to proportional fonts for body prose while
keeping --hotty-font on code or tabular numbers that need to align with
surrounding cells:
body { font-family: sans-serif; }
code, .num { font-family: var(--hotty-font); }
Custom fonts can be bundled as in-band resources and referenced with cid: in
@font-face, or loaded from the network when both host and document policies
allow it (Images and the network):
@font-face { font-family: Inter; src: url(cid:inter); }
One device pixel
--hotty-px equals one physical device pixel in CSS pixels (1px divided by
the host's scale, §8). Use it for crisp 1px hairlines and borders at any zoom
level or display density:
hr { border: 0; border-top: var(--hotty-px) solid var(--hotty-ansi-8); }
Zooming changes only the device-pixel-to-CSS-pixel ratio (§5.3); cell sizes,
root font size, and layout remain unchanged (similar to browser page zoom). The
host re-renders surfaces sharply with the updated --hotty-px.
| event | host behavior | program notification |
|---|---|---|
| zoom or display DPI change | repaints all surfaces at the new scale without reflow | none |
| terminal font change | reflows all documents for the new cell metrics | caps with updated cellcss |
| terminal theme change | updates host stylesheet and repaints all surfaces | caps with updated scheme (only if dark/light changed) |
The scale field in capabilities reports the device-pixel ratio at query time
as a sizing hint for raster images. Supplying images scaled by scale keeps
them sharp at initial render, though subsequent zoom changes happen silently.
CSS the host reads
Certain CSS properties control host behavior in addition to rendering:
| property | host behavior |
|---|---|
overflow |
in scrollable documents, auto and scroll enable element scrolling (Surfaces) |
overscroll-behavior |
prevents scroll chaining out to the host terminal |
scrollbar-width, scrollbar-color, scrollbar-gutter |
styles host scrollbars |
scroll-snap-type, scroll-snap-align, scroll-padding |
snaps scroll positions on rest, as in a browser (new in 0.6) |
cursor |
sets the pointer cursor over the element |
user-select |
none prevents starting a text selection on the element |
touch-action |
on elements with data-on="drag", determines whether touch gestures drag or scroll (Pointers and touch) |
What CSS a host handles
The corpus defines the HTML and CSS feature set hosts are expected to support, with test pages designed to render cleanly at 80×24 cells:
- cards and typography: flexbox, headings, lists, blockquotes, and
pre; - grids and tables:
grid-template-areas,fr,minmax(),colspan, andborder-collapse; - form controls: text fields, checkboxes, radio buttons, ranges, selects, progress bars, and meters;
- visual effects: shadows, gradients, transforms,
opacity,clip-path, andfilter; - Unicode: CJK, emoji, right-to-left text, and combining marks;
- modern selectors and values:
:has(),:is(), nesting,@layer,calc(),clamp(),aspect-ratio, and container queries; - overflow and positioning:
text-overflow,position: sticky, and absolute positioning; - SVG and raster images, including
currentColoricons.
Because not every host uses a browser engine, hosts validate their rendering of the corpus against a browser reference. Exact pixels inside a surface may vary across hosts (for example, font rasterization), but the cell bounds a surface covers must match exactly (§5.3).
Surfaces are sandboxed rather than full web pages, so several CSS capabilities are restricted at the surface boundary (Security):
- nothing can paint outside the surface rectangle, including
position: fixed; url(),@import, and@font-facecan load only in-band resources (cid:),data:URLs, and URLs allowed by the network policy (Images and the network);- nothing scrolls unless the document explicitly enables scrolling (Surfaces).