Text & keywords
Strings and identifiers, the keywords every property accepts, and the types used for font families, font sizes, list counters and text edges. The font and text properties that use them are under Fonts and Text; var(), attr() and counter() are under Values & references.
Strings & identifiers
<string>
Text in double or single quotes. A quote of the same kind, a backslash or a newline inside the string must be escaped with a backslash; \A is a line break and \2014 the character U+2014.
| Definition | Characters enclosed in " or ', with backslash escapes |
|---|---|
| Used by | content, quotes, grid-template-areas, list-style-type, quoted names in font-family, and @import |
| Support | Chrome 1 · Firefox 1 · Safari 1 |
| Spec | css-values-4 |
.note::before { content: "Note:\A"; white-space: pre; }
<ident>
Any CSS identifier: an unquoted name such as auto, sans-serif or my-grid. It starts with a letter, an underscore, a non-ASCII character, a hyphen followed by one of those, or two hyphens, and continues with letters, digits, hyphens and underscores. Other characters can be included with backslash escapes.
| Definition | An unquoted name matching the <ident-token> grammar |
|---|---|
| Used by | Every keyword in every property; the base of <custom-ident> and <dashed-ident> |
| Spec | css-values-4 |
Keywords defined by CSS are matched case-insensitively within the ASCII range, so AUTO works. An identifier in quotes is a <string>, not an identifier.
<custom-ident>
A name you make up, such as an animation name or a grid line name. Unlike CSS keywords it is case-sensitive, so Fade and fade are different names.
| Definition | An <ident> that is not one of the CSS-wide keywords, not default, and not a keyword the property already defines |
|---|---|
| Used by | animation-name, container-name, view-transition-name, grid line names in grid-template-columns, counter names in counter-reset, and @keyframes, @layer and @counter-style names |
| Spec | css-values-4 |
A name that clashes with a keyword in the same property is invalid there: animation-name: none means no animation, never a set of keyframes called none.
<dashed-ident>
A <custom-ident> that must start with two hyphens, like a custom property name. The prefix keeps author names from ever clashing with keywords CSS adds later.
| Definition | A case-sensitive <custom-ident> beginning with -- |
|---|---|
| Used by | Custom properties and var(), anchor-name, position-anchor, @position-try names, scroll-timeline-name, view-timeline-name |
| Spec | css-values-4 |
.trigger { anchor-name: --menu-button; }
.menu { position-anchor: --menu-button; }
CSS-wide keywords
inherit, initial, unset, revert, revert-layer, revert-rule
Keywords that every property accepts, including custom properties. Instead of giving a value, they tell the cascade where to take the value from. Each must be the only thing in the declaration; it cannot be combined with other values.
| Syntax | inherit | initial | unset | revert | revert-layer | revert-rule |
|---|---|
| Used by | Every property, and the all shorthand to reset everything at once |
| Support | inherit: Chrome 1 · Firefox 1 · Safari 1initial: Chrome 1 · Firefox 19 · Safari 1.2unset: Chrome 41 · Firefox 27 · Safari 9.1revert: Chrome 84 · Firefox 67 · Safari 9.1revert-layer: Chrome 99 · Firefox 97 · Safari 15.4revert-rule: Chrome 148 · Firefox 150 · Safari 27 |
| Spec | css-cascade-5 |
| Keyword | Value used |
|---|---|
inherit | The parent element's computed value, even for properties that do not normally inherit. |
initial | The property's initial value from the specification, not the browser's default style. display: initial is inline, even on a div. |
unset | inherit for inherited properties such as color, initial for the rest. |
revert | The value from the previous cascade origin: in an author stylesheet, the user's or the browser's own style for that element. |
revert-layer | The value from the previous cascade layer, as if this layer had not set the property. |
revert-rule | The value the property would have had if the current style rule had not set it. |
button.plain { all: unset; }
.prose ul { list-style: revert; }
Fonts
<generic-font-family>
Keywords that ask for a kind of font rather than a named one. The browser maps each to an installed font, so a generic family is the usual last item in a font-family list. CSS 2 called this type <generic-family>. Generic names are keywords and must not be quoted: "serif" looks for a font actually called serif.
| Syntax | <generic-font-script-specific>| <generic-font-complete> | <generic-font-incomplete> |
|---|---|
| Used by | font-family, font |
| Spec | css-fonts-4 |
| Keyword | Font | Support |
|---|---|---|
serif | A font with serifs, such as Times. | All browsers |
sans-serif | A font without serifs, such as Helvetica or Arial. | All browsers |
monospace | A font whose characters all have the same width. | All browsers |
cursive | A script or handwriting-style font. | All browsers |
fantasy | A decorative display font. | All browsers |
system-ui | The operating system's interface font. | Chrome 56 · Firefox 92 · Safari 11 |
math | A font designed for mathematical notation. | Chrome 109 · Firefox 149 · Safari 26.2 |
ui-serif | The system's serif interface font, such as New York on Apple platforms. | Chrome no · Firefox no · Safari 13.1 |
ui-sans-serif | The system's sans-serif interface font. | Chrome no · Firefox no · Safari 13.1 |
ui-monospace | The system's monospace interface font, such as SF Mono. | Chrome no · Firefox no · Safari 13.1 |
ui-rounded | The system's rounded interface font, such as SF Pro Rounded. | Chrome no · Firefox no · Safari 13.1 |
The ui-* keywords match nothing when the system has no such font, so the next family in the list is used.
font-family: ui-monospace, "Cascadia Code", Menlo, monospace;
<family-name>
The name of a particular font family, such as Georgia or "Helvetica Neue". It can be a quoted string, or one or more unquoted identifiers separated by spaces.
| Definition | A <string>, or a sequence of one or more <custom-ident>s |
|---|---|
| Used by | font-family, font, and the font-family descriptor of @font-face |
| Spec | css2 |
Quote any name that contains digits at the start of a word, punctuation, or a word that is also a generic family or CSS-wide keyword. Quoting every multi-word name is the simplest rule.
<absolute-size>
Font size keywords on a fixed scale. medium is the user's preferred font size, usually 16px; the other keywords step up and down from it. Browsers round the results, so exact sizes vary slightly.
| Syntax | [ xx-small | x-small | small | medium | large | x-large | xx-large | xxx-large ] |
|---|---|
| Used by | font-size, font |
| Spec | css-fonts-4 |
| Keyword | Suggested scale |
|---|---|
xx-small | 3/5 |
x-small | 3/4 |
small | 8/9 |
medium | 1 |
large | 6/5 |
x-large | 3/2 |
xx-large | 2 |
xxx-large | 3 |
xxx-large is newer than the others: Chrome 79 · Firefox 70 · Safari 16.4.
<relative-size>
A font size one step larger or smaller than the parent's. Browsers move along the <absolute-size> scale, or multiply by a ratio of about 1.2 when the parent's size is between steps.
| Syntax | [ larger | smaller ] |
|---|---|
| Used by | font-size, font |
| Spec | css-fonts-4 |
Counters & text edges
<counter-style>
How a counter value is turned into a marker: decimal numbers, letters, roman numerals, a bullet symbol, or a numbering system for another script. It is the name of a predefined style or of one you define with @counter-style, or an anonymous style made with symbols().
| Syntax | <counter-style-name> | <symbols()> |
|---|---|
| Used by | list-style-type, counter() and counters(), and the system: extends and fallback descriptors of @counter-style |
| Spec | css-counter-styles-3 |
<counter-style-name> is a <custom-ident>; the predefined names are matched case-insensitively, author-defined ones case-sensitively. symbols() ships in Firefox 35 and Chrome 155 only.
| Kind | Predefined styles |
|---|---|
| Numeric | decimal (1, 2, 3), decimal-leading-zero (01, 02), lower-roman (i, ii), upper-roman (I, II), armenian, lower-armenian, upper-armenian, georgian, hebrew, arabic-indic, persian, bengali, devanagari, gujarati, gurmukhi, kannada, malayalam, oriya, tamil, telugu, khmer, cambodian, lao, myanmar, mongolian, thai, tibetan, cjk-decimal |
| Alphabetic | lower-alpha / lower-latin (a, b), upper-alpha / upper-latin (A, B), lower-greek (α, β), hiragana, hiragana-iroha, katakana, katakana-iroha |
| Symbolic | disc (•), circle (◦), square (▪), disclosure-open (▾), disclosure-closed (▸) |
| Fixed | cjk-earthly-branch, cjk-heavenly-stem |
| Spelled-out | cjk-ideographic, japanese-informal, japanese-formal, korean-hangul-formal, korean-hanja-informal, korean-hanja-formal, simp-chinese-informal, simp-chinese-formal, trad-chinese-informal, trad-chinese-formal, ethiopic-numeric |
| Chrome and Safari only | upper-greek, binary, octal, lower-hexadecimal, upper-hexadecimal, lower-norwegian, upper-norwegian, hangul, hangul-consonant, urdu, asterisks, footnotes, and Ethiopic styles such as amharic and ethiopic-halehame |
ol.legal { list-style-type: upper-roman; }
li::after { content: " (" counter(list-item, lower-alpha) ")"; }
<text-edge>
Which font metric marks the top and bottom edge of a line of text when trimming the extra space above and below it. The first keyword sets the over edge and the second the under edge; text on its own sets both.
| Syntax | [ text | ideographic | ideographic-ink ] | [ text | ideographic | ideographic-ink | cap | ex ] [ text | ideographic | ideographic-ink | alphabetic ] |
|---|---|
| Used by | text-box-edge, text-box |
| Support | Chrome 133 · Firefox no · Safari 18.2 |
| Spec | css-inline-3 |
| Keyword | Edge |
|---|---|
text | The font's ascent (over) or descent (under), the normal edges of the text. |
cap | Over edge only: the top of capital letters. |
ex | Over edge only: the x-height, the top of lowercase letters. |
alphabetic | Under edge only: the alphabetic baseline. |
.button { text-box: trim-both cap alphabetic; }