CHA-CSS(7)
π CSS in Chawan π
okay bestie, this is the CHA-CSS(7) manual page from the Miscellaneous Information Manual, and it's literally all about the CSS that Chawan supports, plus its proprietary extensions and where it deviates from standards. no cap.
This doc describes the 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 https://todo.sr.ht/~bptato/chawan.
β¨ Standard properties β¨
hereβs the list of supported standard properties, with lil notes on values that arenβt implemented yet:
align-itemsβ flex only;baselineis treated asflex-startalign-selfβ see abovebackground-colorβ seecolorbackground-imageβ displays placeholders onlyborder-collapseborder-*-style,border-*-color,border-*-widthβ but see bordersborder-spacingbottombox-sizingcaption-sideclearcolorβ hex values, colors except system keywords, and functionsrgb,rgba,hsl,hsla,oklab,oklch; see limitations on relative colors (βfromβ keyword) belowcontentβ string,(no-)open/close-quote,counter()counter-incrementcounter-resetcounter-setdisplayβblock,inline-block,list-item,table,inline-table,table-*,flex,inline-flex,flow-root, as well as multi-keyword aliases (including list-item variants)flex-basisβ butcontentnot supportedflex-directionflex-growflex-shrinkflex-wrapfloatfont-sizeβ ignored; only for JS compatibilityfont-styleβobliqueinterpreted asitalicfont-weightβ numeric properties> 500interpreted as bold, others as regularheightjustify-contentβ flex onlyleftlist-style-positionlist-style-typeβ but no custom list stylesmargin-bottommargin-leftmargin-rightmargin-topmax-heightmax-widthmin-heightmin-widthopacityβ hacky; only works withopacity: 0overflow-xβ see below on scrollbarsoverflow-yβ see below on scrollbarspadding-bottompadding-leftpadding-rightpadding-toppositionβ see below for sticky and fixedquotesrighttext-aligntext-decorationβnone,underline,overline,line-throughtext-transformtopvertical-alignvisibilitywhite-spacewidthword-breakz-index
π Shorthands π
allmarginpaddingborder,border-style,border-color,border-widthβ but see bordersbackgroundβ only color and url; other components are skippedinsetlist-styleβlist-style-imageis skippedflexflex-flowoverflow
Variables (the var() function) are fully supported.
Values of <length> or absolute <color> types support calc() expressions. However, colors relative to currentcolor, as well as named color components in calc expressions (e.g. hsl(from currentcolor 9 s l) or hsl(from hsl(20, 50, 50) calc(h + 9) s l)) are not supported.
Logical properties such as margin-inline-start etc. are currently not supported (and neither is writing-mode). However, for compatibility, they are treated as aliases to the respective physical properties with writing-mode: horizontal-tb.
π Selectors π
All selector types from CSS 2.1 are supported, except for XML 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, :empty.
: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 π
text-alignaccepts the values-cha-center,-cha-left, and-cha-rightto support the HTML<center>,<div align=left>and<div align=right>elements. (Analogous to-moz-centeretc.)- Properties with a
<color>value accept the function-cha-ansi(), mapping to terminal-specific (βANSIβ) colors. The function takes one of- An 8-bit integer, indicating a color value as set by XTermβs indexed color feature.
- 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.
text-decorationaccepts 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<code>tags.)text-transformaccepts 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.
- The
-cha-colspanand-cha-rowspanproperties have the same effect as thecolspanandrowspanattributes on tables. - The
:-cha-first-nodeand:-cha-last-nodepseudo-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-nodeand:-moz-last-node.) - If
buffer.mark-linksis set, the::-cha-link-markerpseudo-element will be generated on all anchor elements. - In hints mode (by default, the
fkey) the markers are implemented by generating::-cha-link-hinton all applicable elements. So you can change the marker background in your user-style ([buffer]section incha-config(5)):
::-cha-link-hint { background: gainsboro }
- The
-cha-content-typemedia 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.
- If
overflowisautoorscroll, and the intrinsic minimum size of the box is greater than its specified size, then the former overrides the latter. - 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:
position: stickyis treated asposition: static, except it also behaves as an absolute position container.position: fixedis 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:
- On tables, borders are always collapsed, even when
border-collapseis set toseparate. - With
border-collapse: separate, the spacing between cells is the largest ofborder-spacingtimes two and the cell width. border-*-widthis interpreted as a binary value: a width of0results 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).box-sizing: border-boxβ lowkey the icon of this whole list π it actually sets the padding box size, not the content box. Which means borders that get rounded up to the cell size don't accidentally eat all the space that was supposed to be for your actual content π«Ά and that matters, because if they did, you'd get problems the second a child box setoverflow: hidden, etc. π so yeah, it's giving "protective big sibling" energy fr fr.
π¦ See also π¦
cha(1)β go say hi to the main character, she runs the whole show π
okay that's genuinely the end of the page bestie, no cap π everything above is straight from theCHA-CSS(7)manual page β Chawan's very own CSS notes, filed underCHA-CSS(7)in the manual set. mwah, go build something iconic β¨ππ¦
π¦ where this page comes from
- arch rolling: chawan 0.5.0-1 Β· Unlicense
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms