about summary refs log tree commit diff stats
path: root/doc/cha-css.7
blob: b141e39ae107f659f5346c5fe809af68e250a376 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
.\" Automatically generated by Pandoc 3.6.1
.\"
.TH "cha\-css" "7" "" "" "Image support in Chawan"
.SH CSS in Chawan
This document describes CSS properties supported by Chawan, as well as
its proprietary extensions and deviations from standards.
.PP
If you discover a deviation that is not covered by this document, please
open a ticket at \c
.UR https://todo.sr.ht/~bptato/chawan
.UE \c
\&.
.SS Standard properties
A list of supported standard properties, with notes on unimplemented
values:
.IP \[bu] 2
background\-color (see color)
.IP \[bu] 2
background\-image (displays placeholders only)
.IP \[bu] 2
border\-collapse
.IP \[bu] 2
border\-spacing
.IP \[bu] 2
bottom
.IP \[bu] 2
box\-sizing
.IP \[bu] 2
caption\-side
.IP \[bu] 2
clear
.IP \[bu] 2
color (hex values and functions \f[CR]rgb\f[R], \f[CR]rgba\f[R],
\f[CR]hsl\f[R], \f[CR]hsla\f[R])
.IP \[bu] 2
content (string, (no\-)open/close\-quote, counter())
.IP \[bu] 2
counter\-increment
.IP \[bu] 2
counter\-reset
.IP \[bu] 2
counter\-set
.IP \[bu] 2
display (\f[CR]block\f[R], \f[CR]inline\-block\f[R],
\f[CR]list\-item\f[R], \f[CR]table\f[R], \f[CR]table\-*\f[R],
\f[CR]flex\f[R], \f[CR]inline\-flex\f[R], \f[CR]flow\-root\f[R])
.IP \[bu] 2
flex\-basis (but \f[CR]content\f[R] not supported)
.IP \[bu] 2
flex\-direction
.IP \[bu] 2
flex\-grow
.IP \[bu] 2
flex\-shrink
.IP \[bu] 2
flex\-wrap
.IP \[bu] 2
float
.IP \[bu] 2
font\-size (ignored; only for JS compatibility)
.IP \[bu] 2
font\-style (\f[CR]oblique\f[R] interpreted as \f[CR]italic\f[R])
.IP \[bu] 2
font\-weight (numeric properties > 500 interpreted as bold, others as
regular)
.IP \[bu] 2
height
.IP \[bu] 2
left
.IP \[bu] 2
list\-style\-position
.IP \[bu] 2
list\-style\-type (but no custom list styles)
.IP \[bu] 2
margin\-bottom
.IP \[bu] 2
margin\-left
.IP \[bu] 2
margin\-right
.IP \[bu] 2
margin\-top
.IP \[bu] 2
max\-height
.IP \[bu] 2
max\-width
.IP \[bu] 2
min\-height
.IP \[bu] 2
min\-width
.IP \[bu] 2
opacity (hacky; only works with \f[CR]opacity: 0\f[R])
.IP \[bu] 2
overflow\-x (see below on scrollbars)
.IP \[bu] 2
overflow\-y (see below on scrollbars)
.IP \[bu] 2
padding\-bottom
.IP \[bu] 2
padding\-left
.IP \[bu] 2
padding\-right
.IP \[bu] 2
padding\-top
.IP \[bu] 2
position (see below for \f[CR]sticky\f[R] and \f[CR]fixed\f[R])
.IP \[bu] 2
quotes
.IP \[bu] 2
right
.IP \[bu] 2
text\-align
.IP \[bu] 2
text\-decoration (\f[CR]none\f[R], \f[CR]underline\f[R],
\f[CR]overline\f[R], \f[CR]line\-through\f[R])
.IP \[bu] 2
text\-transform
.IP \[bu] 2
top
.IP \[bu] 2
vertical\-align
.IP \[bu] 2
visibility
.IP \[bu] 2
white\-space
.IP \[bu] 2
width
.IP \[bu] 2
word\-break
.IP \[bu] 2
z\-index
.PP
Shorthands:
.IP \[bu] 2
all
.IP \[bu] 2
margin
.IP \[bu] 2
padding
.IP \[bu] 2
background (only color and url; other components are skipped)
.IP \[bu] 2
list\-style (list\-style\-image is skipped)
.IP \[bu] 2
flex
.IP \[bu] 2
flex\-flow
.IP \[bu] 2
overflow
.PP
Variables (the \f[CR]var\f[R] function) are supported only for
non\-shorthand properties and the \f[CR]background\f[R] shorthand.
.PP
Values with a \f[CR]<length>\f[R] type support very simple
\f[CR]calc()\f[R] expressions that consist of one addition or
subtraction and do not use the \f[CR]var\f[R] function.
.SS Proprietary extensions
.IP \[bu] 2
\f[CR]text\-align\f[R] accepts the values \f[CR]\-cha\-center\f[R],
\f[CR]\-cha\-left\f[R], and \f[CR]\-cha\-right\f[R] to support the HTML
\f[CR]<center>\f[R], \f[CR]<div align=left>\f[R] and
\f[CR]<div align=right>\f[R] elements.
(Analogous to \f[CR]\-moz\-center\f[R] etc.)
.IP \[bu] 2
Properties with a \f[CR]<color>\f[R] value accept the function
\f[CR]\-cha\-ansi()\f[R], which takes one parameter that is either:
.IP \[bu] 2
An 8\-bit integer, indicating a color value as set by XTerm\[cq]s
indexed color feature.
.IP \[bu] 2
One of the strings \[lq]black\[rq], \[lq]red\[rq], \[lq]green\[rq],
\[lq]yellow\[rq], \[lq]blue\[rq], \[lq]magenta\[rq], \[lq]cyan\[rq],
\[lq]white\[rq] for an ANSI color, possibly prefixed by the string
\[lq]bright\-\[rq] to indicate an aixterm 16\-color value.
.PP
The actual palette in use is specified by the user/terminal.
.IP \[bu] 2
\f[CR]text\-decoration\f[R] accepts the keyword
\f[CR]\-cha\-reverse\f[R], which sets the \f[I]reverse video\f[R]
parameter on the text.
(This is used by the UA style sheet to highlight text in
\f[CR]<code>\f[R] tags.)
.IP \[bu] 2
\f[CR]text\-transform\f[R] accepts the keyword
\f[CR]\-cha\-half\-width\f[R], which has the opposite effect as
\f[CR]full\-width\f[R].
This can be used in user style sheets to compress distracting ruby text:
\f[CR]rt{text\-transform: \-cha\-half\-width}\f[R].
Characters without half\-width counterparts are left intact, except
hiragana is treated as katakana.
.IP \[bu] 2
The \f[CR]\-cha\-colspan\f[R] and \f[CR]\-cha\-rowspan\f[R] properties
have the same effect as the \f[CR]colspan\f[R] and \f[CR]rowspan\f[R]
attributes on tables.
.IP \[bu] 2
The \f[CR]\-cha\-first\-node\f[R] and \f[CR]\-cha\-last\-node\f[R]
selectors 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 \f[CR]\-moz\-first\-node\f[R] and
\f[CR]\-moz\-last\-node\f[R].)
.IP \[bu] 2
If \f[CR]buffer.mark\-links\f[R] is set, the
\f[CR]::\-cha\-link\-marker\f[R] pseudo\-element will be generated on
all anchor elements.
.SS 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.
.SS 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\[cq]s rendering.
In general, faithfulness to w3m is preferred over the standard\[cq]s
suggestions, unless those break on existing websites.
.PP
Link colors differ depending on the terminal\[cq]s color scheme.
.SS 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.)
.PP
In case of Kitty images, the fractional part is preserved, and is used
as an in\-cell offset.
.PP
The lengths \f[CR]1em\f[R] and \f[CR]1ch\f[R] compute to the cell height
and cell width respectively.
.PP
In outer inline boxes (\f[CR]inline\-block\f[R],
\f[CR]inline\-flex\f[R]) and \f[CR]list\-item\f[R] boxes, margins and
padding that are smaller than one cell (on the respective axis) are
ignored.
This does not apply to blockified inline boxes.
.PP
When calculating clip boxes (\f[CR]overflow: hidden\f[R] or
\f[CR]clip\f[R]), the clip box\[cq]s offset is floored, and its size is
ceiled to the nearest cell\[cq]s boundaries.
This means that \[lq]width: 1px; overflow: hidden\[rq] will still
display the first character of a text box.
.SS Scroll bars
Chawan does not have scroll bars, as they would complicate on\-page
navigation and would not work in dump mode.
Instead, the \[lq]overflow\-x/y\[rq] properties are handled as follows.
.IP "1." 3
If \f[CR]overflow\f[R] is \f[CR]auto\f[R] or \f[CR]scroll\f[R], and the
intrinsic minimum size of the box is greater than its specified size,
then the former overrides the latter.
.IP "2." 3
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.
.SS \f[CR]position: fixed\f[R], \f[CR]position: sticky\f[R]
To keep the document model static, these do not change their position
based on the viewport\[cq]s scroll status.
Instead:
.IP \[bu] 2
\f[CR]position: sticky\f[R] is treated as \f[CR]position: static\f[R],
except it also behaves as an absolute position container.
.IP \[bu] 2
\f[CR]position: fixed\f[R] is placed at the bottom of the document.
.PP
Right now, \f[CR]position: fixed\f[R] is always positioned at the bottom
of the root element\[cq]s margin box.
This breaks on pages that overflow it (e.g.
by setting \f[CR]height: 100%\f[R] on the root element), so it will be
moved to the bottom of its overflow box in the future.
.SS Color correction
Some authors only specify one of the foreground or the background color,
assuming a black\-on\-white canvas.
The \f[CR]display.minimum\-contrast\f[R] 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.)
.PP
This unfortunately breaks spoiler mechanisms that rely on \[lq]black on
black\[rq] text not being visible.
The issue disappears when \f[CR]visibility: hidden\f[R] is applied to
the text as well.
.SS See also
\f[B]cha\f[R](1)