CHA-CSS(7) Miscellaneous Information Manual CHA-CSS(7) CSS in Chawan This document describes CSS features supported by Chawan, as well as its proprietary extensions and deviations from standards. If you discover a deviation that is not covered by this document, please open a ticket at . Standard properties A list of supported standard properties, with notes on unimplemented values: o background-color (see color) o background-image (displays placeholders only) o border-collapse o border-*-style, border-*-color, border-*-width (but see borders) o border-spacing o bottom o box-sizing o caption-side o clear o color (hex values and functions rgb, rgba, hsl, hsla) o content (string, (no-)open/close-quote, counter()) o counter-increment o counter-reset o counter-set o display (block, inline-block, list-item, table, table-*, flex, inline-flex, flow-root) o flex-basis (but content not supported) o flex-direction o flex-grow o flex-shrink o flex-wrap o float o font-size (ignored; only for JS compatibility) o font-style (oblique interpreted as italic) o font-weight (numeric properties > 500 interpreted as bold, others as regular) o height o left o list-style-position o list-style-type (but no custom list styles) o margin-bottom o margin-left o margin-right o margin-top o max-height o max-width o min-height o min-width o opacity (hacky; only works with opacity: 0) o overflow-x (see below on scrollbars) o overflow-y (see below on scrollbars) o padding-bottom o padding-left o padding-right o padding-top o position (see below for sticky and fixed) o quotes o right o text-align o text-decoration (none, underline, overline, line-through) o text-transform o top o vertical-align o visibility o white-space o width o word-break o z-index Shorthands: o all o margin o padding o border, border-style, border-color, border-width (but see borders) o background (only color and url; other components are skipped) o list-style (list-style-image is skipped) o flex o flex-flow o overflow Variables (the var() function) are fully supported. Values of or types fully support calc() expressions. Selectors All selector types from CSS 2.1 are supported, except for namespaces. Following standard pseudo-classes are supported: :first-child, :last-child, :only-child, :hover, :root, :nth-child(), :nth-last-child(), :checked, :focus, :is(), :not(), :where(), :lang(), :link, :target, :disabled. :visited is parsed, but for now it is not matched. :defined, :host, and :host() are matched for compatibility; however, custom elements and shadow DOM are not supported yet. The standard pseudo-elements ::before, ::after, and ::marker are supported. ::backdrop is parsed for compatibility, but is not supported yet. At-rules Following rules starting with an @ sign are supported. @media The grid, hover, prefers-color-scheme, scripting, width, and height media features are fully supported. The color, color-index, and monochrome features are supported, but only consider the number of supported text colors (which can differ from the number of colors in Sixel/Kitty images). @import Importing to layers is supported. @import combined with media queries is not yet supported. @layer @layer is fully supported. (I think.) Proprietary extensions o text-align accepts the values -cha-center, -cha-left, and -cha-right to support the HTML
,
and
elements. (Analogous to -moz-center etc.) o Properties with a value accept the function -cha-ansi(), mapping to terminal-specific ("ANSI") colors. The function takes one of o An 8-bit integer, indicating a color value as set by XTerm's indexed color feature. o One of the strings "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white" for an ANSI color, possibly prefixed by the string "bright-" to indicate an aixterm 16-color value. o text-decoration accepts the keyword -cha-reverse, which sets the reverse video parameter on the text. (This is used by the UA style sheet to highlight text in tags.) o text-transform accepts the keyword -cha-half-width, which has the opposite effect as full-width. This can be used in user style sheets to compress distracting ruby text: rt{text-transform: -cha-half-width}. Characters without half-width counterparts are left intact, except hiragana is treated as katakana. o The -cha-colspan and -cha-rowspan properties have the same effect as the colspan and rowspan attributes on tables. o The :-cha-first-node and :-cha-last-node pseudo-classes apply to elements that have no preceding/subsequent sibling node that is either an element node or a text node with non-whitespace contents. (Modeled after :-moz-first-node and :-moz-last-node.) o If buffer.mark-links is set, the ::-cha-link-marker pseudo-element will be generated on all anchor elements. o In hints mode (by default, the f key) the markers are implemented by generating ::-cha-link-hint on all applicable elements. So you can change the marker background in your user-style ([buffer] section in config.toml): ::-cha-link-hint { background: gainsboro } o The -cha-content-type media feature can be used to filter documents for their content type. For example, you can add @media (-cha-content-type: "text/markdown") { body { width: 80ch } } to your user-style to set the body width of all markdown documents to 80 characters. (The string is matched case-insensitively.) Rendering quirks These are willful violations of the standard, usually made to better fit the display model inherent to projecting the web to a cell-based screen. User agent style sheet The user agent style sheet is a combination of the styles suggested by the HTML standard and a CSS port of w3m's rendering. In general, faithfulness to w3m is preferred over the standard's suggestions, unless w3m's rendering breaks on existing websites. Link colors differ depending on the terminal's color scheme. Sizing and positioning Layout is performed on a finite canvas of coordinates represented by a 32-bit fixed-point number with 6 bits of precision. After layout, these positions are divided by the cell width and/or height, with the fractional part truncated. (This is subject to change.) In case of Kitty images, the fractional part is preserved, and is used as an in-cell offset. The lengths 1em and 1ch compute to the cell height and cell width respectively. In outer inline boxes (inline-block, inline-flex) and list-item boxes, margins and padding that are smaller than one cell (on the respective axis) are ignored. This does not apply to blockified inline boxes. When calculating clip boxes (overflow: hidden or clip), the clip box's offset is floored, and its size is ceiled to the nearest cell's boundaries. This means that "width: 1px; overflow: hidden" will still display the first character of a text box. Scroll bars Chawan does not have scroll bars, as they would complicate on-page navigation and would not work in dump mode. Instead, the "overflow-x/y" properties are handled as follows. 1. If overflow is auto or scroll, and the intrinsic minimum size of the box is greater than its specified size, then the former overrides the latter. 2. Content that spills out of a scroll container on the X axis is displayed, while content that spills out of a scroll container on the Y axis is clipped. position: fixed, position: sticky To keep the document model static, these do not change their position based on the viewport's scroll status. Instead: o position: sticky is treated as position: static, except it also behaves as an absolute position container. o position: fixed is placed at the bottom of the document. Right now, position: fixed is always positioned at the bottom of the root element's margin box. This breaks on pages that overflow it (e.g. by setting height: 100% on the root element), so it will be moved to the bottom of its overflow box in the future. Color correction Some authors only specify one of the foreground or the background color, assuming a black-on-white canvas. The display.minimum-contrast option adjusts the foreground color so that text remains readable even if the terminal background does not match this expectation. (The exact algorithm is unspecified and subject to change.) To avoid breaking spoiler mechanisms that rely on "black on black" text, color correction is not invoked on cells that have an RGB color (typically specified by the author.) Borders CSS borders are difficult to accurately display on a cell-based display. So while the functionality exists, it has some limitations: o On tables, borders are always collapsed, even when border-collapse is set to separate. o With border-collapse: separate, the spacing between cells is the largest of border-spacing times two and the cell width. o border-*-width is interpreted as a binary value: a width of 0 results in no border, while any other width results in a border of a single type. If the width is smaller than one cell (in the respective direction), the rest is subtracted from the margin (if there is any margin). o box-sizing: border-box actually sets the padding box size, so that borders rounded up to the cell size do not accidentally take all space from the actual content. (That in turn would cause problems if a child box set overflow: hidden, etc.) See also cha(1) CHA-CSS(7)