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.

DefinitionCharacters enclosed in " or ', with backslash escapes
Used bycontent, quotes, grid-template-areas, list-style-type, quoted names in font-family, and @import
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-values-4
.note::before { content: "Note:\A"; white-space: pre; }
Generated text followed by a line break.

<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.

DefinitionAn unquoted name matching the <ident-token> grammar
Used byEvery keyword in every property; the base of <custom-ident> and <dashed-ident>
Speccss-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.

DefinitionAn <ident> that is not one of the CSS-wide keywords, not default, and not a keyword the property already defines
Used byanimation-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
Speccss-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.

DefinitionA case-sensitive <custom-ident> beginning with --
Used byCustom properties and var(), anchor-name, position-anchor, @position-try names, scroll-timeline-name, view-timeline-name
Speccss-values-4
.trigger { anchor-name: --menu-button; }
.menu { position-anchor: --menu-button; }
Naming an anchor and positioning against it.

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.

Syntaxinherit | initial | unset | revert | revert-layer | revert-rule
Used byEvery property, and the all shorthand to reset everything at once
Supportinherit: Chrome 1 · Firefox 1 · Safari 1
initial: Chrome 1 · Firefox 19 · Safari 1.2
unset: Chrome 41 · Firefox 27 · Safari 9.1
revert: Chrome 84 · Firefox 67 · Safari 9.1
revert-layer: Chrome 99 · Firefox 97 · Safari 15.4
revert-rule: Chrome 148 · Firefox 150 · Safari 27
Speccss-cascade-5
KeywordValue used
inheritThe parent element's computed value, even for properties that do not normally inherit.
initialThe property's initial value from the specification, not the browser's default style. display: initial is inline, even on a div.
unsetinherit for inherited properties such as color, initial for the rest.
revertThe value from the previous cascade origin: in an author stylesheet, the user's or the browser's own style for that element.
revert-layerThe value from the previous cascade layer, as if this layer had not set the property.
revert-ruleThe value the property would have had if the current style rule had not set it.
button.plain { all: unset; }
.prose ul { list-style: revert; }
Strip a button back to bare text, and bring back the browser's list bullets after a reset.

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 byfont-family, font
Speccss-fonts-4
KeywordFontSupport
serifA font with serifs, such as Times.All browsers
sans-serifA font without serifs, such as Helvetica or Arial.All browsers
monospaceA font whose characters all have the same width.All browsers
cursiveA script or handwriting-style font.All browsers
fantasyA decorative display font.All browsers
system-uiThe operating system's interface font.Chrome 56 · Firefox 92 · Safari 11
mathA font designed for mathematical notation.Chrome 109 · Firefox 149 · Safari 26.2
ui-serifThe system's serif interface font, such as New York on Apple platforms.Chrome no · Firefox no · Safari 13.1
ui-sans-serifThe system's sans-serif interface font.Chrome no · Firefox no · Safari 13.1
ui-monospaceThe system's monospace interface font, such as SF Mono.Chrome no · Firefox no · Safari 13.1
ui-roundedThe 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;
A code font stack ending in a generic family.

<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.

DefinitionA <string>, or a sequence of one or more <custom-ident>s
Used byfont-family, font, and the font-family descriptor of @font-face
Speccss2

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 byfont-size, font
Speccss-fonts-4
KeywordSuggested scale
xx-small3/5
x-small3/4
small8/9
medium1
large6/5
x-large3/2
xx-large2
xxx-large3

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 byfont-size, font
Speccss-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 bylist-style-type, counter() and counters(), and the system: extends and fallback descriptors of @counter-style
Speccss-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.

KindPredefined styles
Numericdecimal (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
Alphabeticlower-alpha / lower-latin (a, b), upper-alpha / upper-latin (A, B), lower-greek (α, β), hiragana, hiragana-iroha, katakana, katakana-iroha
Symbolicdisc (•), circle (◦), square (▪), disclosure-open (▾), disclosure-closed (▸)
Fixedcjk-earthly-branch, cjk-heavenly-stem
Spelled-outcjk-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 onlyupper-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) ")"; }
Roman-numeral list markers, and a counter printed as a letter.

<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 bytext-box-edge, text-box
SupportChrome 133 · Firefox no · Safari 18.2
Speccss-inline-3
KeywordEdge
textThe font's ascent (over) or descent (under), the normal edges of the text.
capOver edge only: the top of capital letters.
exOver edge only: the x-height, the top of lowercase letters.
alphabeticUnder edge only: the alphabetic baseline.
.button { text-box: trim-both cap alphabetic; }
Trim a label from cap height to baseline, so padding looks even above and below.