Text
The properties that lay text out within and across lines: alignment and indentation, spacing, white space, wrapping and hyphenation, case and overflow, underlines and emphasis marks, line height and baseline alignment, ruby annotations and MathML layout. Choosing a font is under Fonts; the text colour is under Color & backgrounds; writing-mode, direction and text-orientation are under Writing modes & logical; SVG's text-anchor is under SVG.
Alignment & indentation
text-align
How the lines of a block are aligned within it in the inline direction. start and end follow the text direction, so they flip for right-to-left languages; left and right do not.
| Syntax | start | end | left | right | center | <string> | justify | match-parent | justify-all |
|---|---|
| Initial | start |
| Applies to | Block containers |
| Inherited | Yes |
| Percentages | See individual properties |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 1 · Safari 1 |
| Spec | css-text-4 |
| Value | Effect |
|---|---|
start / end | Aligned to the start or end edge of the line in the text's direction. |
left / right | Aligned to the physical left or right edge. |
center | Centred. |
justify | Spaces are stretched so each line fills the width, except the last line, which follows text-align-last. |
match-parent | Like inherit, but start and end are resolved against the parent's direction. |
text-align aligns inline content, not the block itself; to centre a block, use margin-inline: auto.
text-align-last
The alignment of the last line of a block, and of any line just before a forced line break. auto follows text-align, except that justified text ends with a line aligned to the start.
| Syntax | auto | start | end | left | right | center | justify | match-parent |
|---|---|
| Initial | auto |
| Applies to | Block containers |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 47 · Firefox 49 · Safari 16 |
| Spec | css-text-4 |
text-justify
How justified text is stretched to fill the line. inter-word widens only the spaces between words, which suits languages such as English; inter-character spaces out every character, which suits Chinese and Japanese; none turns justification off.
| Syntax | [ auto | none | inter-word | inter-character | ruby ] || no-compress |
|---|---|
| Initial | auto |
| Applies to | Text |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 145 · Firefox 55 · Safari no |
| Spec | css-text-4 |
It only has an effect where text-align or text-align-last is justify. auto lets the browser choose a method suited to the language.
text-indent
Indents the first line of a block. A negative value pulls the first line out past the edge, which with matching padding makes a hanging indent.
| Syntax | [ <length-percentage> ] && hanging? && each-line? |
|---|---|
| Initial | 0 |
| Applies to | Block containers |
| Inherited | Yes |
| Percentages | Refer to the block container's own inline-axis inner size |
| Animation | By computed value type |
| Support | Chrome 1 · Firefox 1 · Safari 1 |
| Spec | css-text-4 |
hanging inverts the indent so every line except the first is indented. each-line also indents each line that follows a forced line break, not just the first line of the block.
p + p { text-indent: 1.5em; }
hanging-punctuation
Lets punctuation hang outside the line box, so the edge of the text lines up with the letters rather than the quotation marks. first hangs an opening mark at the start of the first line, last a closing mark at the end of the last line, and force-end or allow-end a stop or comma at the end of a line.
| Syntax | none | [ first || [ force-end | allow-end ] || last ] |
|---|---|
| Initial | none |
| Applies to | Text |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome no · Firefox no · Safari 26.5 |
| Spec | css-text-4 |
Safari supported it from version 10, but did not hang straight quotation marks until 26.5.
Spacing
letter-spacing
Extra space added between characters; negative values tighten. Use em so the spacing scales with the font size. Non-zero spacing turns off the font's optional ligatures.
| Syntax | normal | <length-percentage> |
|---|---|
| Initial | normal |
| Applies to | Inline boxes and text |
| Inherited | Yes |
| Percentages | Relative to the used font-size |
| Animation | By computed value type |
| Support | Chrome 1 · Firefox 1 · Safari 1 |
| Spec | css-text-4 |
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; }
word-spacing
Extra space added to each word separator, on top of the font's own space width. Negative values tighten.
| Syntax | normal | <length-percentage> |
|---|---|
| Initial | normal |
| Applies to | Text |
| Inherited | Yes |
| Percentages | Relative to the used font-size |
| Animation | By computed value type |
| Support | Chrome 1 · Firefox 1 · Safari 1 |
| Spec | css-text-4 |
tab-size
The width of a tab character in preserved white space, as a number of space widths or as a length.
| Syntax | <number [0,∞]> | <length [0,∞]> |
|---|---|
| Initial | 8 |
| Applies to | Text |
| Inherited | Yes |
| Animation | By computed value type |
| Support | Chrome 21 · Firefox 91 · Safari 7 |
| Spec | css-text-4 |
pre { tab-size: 4; }
text-autospace
Adds a small gap where Chinese or Japanese ideographs meet Latin letters or digits, so mixed-script text does not need hand-typed spaces. no-autospace turns it off.
| Syntax | normal | <autospace> | auto |
|---|---|
| Initial | normal |
| Applies to | Text |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 140 · Firefox 145 · Safari 18.4 |
| Spec | css-text-4 |
<autospace> is no-autospace, or a combination of ideograph-alpha (between ideographs and letters) and ideograph-numeric (between ideographs and digits), with further keywords for punctuation.
text-spacing-trim
Controls the blank space built into full-width Chinese and Japanese punctuation such as brackets and commas. normal trims it in places such as between two adjacent punctuation marks; space-all keeps the full width everywhere.
| Syntax | <spacing-trim> | auto |
|---|---|
| Initial | normal |
| Applies to | Text |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 123 · Firefox no · Safari no |
| Spec | css-text-4 |
<spacing-trim> is one of space-all, normal, space-first, trim-start, trim-both or trim-all.
White space & wrapping
white-space
Shorthand for white-space-collapse and text-wrap-mode: whether spaces and line breaks in the source are kept, and whether lines wrap. The single keywords below are the long-standing way to set both.
| Syntax | normal | pre | pre-wrap | pre-line | <'white-space-collapse'> || <'text-wrap-mode'> || <'white-space-trim'> |
|---|---|
| Initial | normal |
| Applies to | Text |
| Inherited | See individual properties |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 1 · Safari 1 |
| Spec | css-text-4 |
| Value | Spaces and tabs | Line breaks | Wrapping |
|---|---|---|---|
normal | Collapsed | Collapsed | Yes |
nowrap | Collapsed | Collapsed | No |
pre | Kept | Kept | No |
pre-wrap | Kept | Kept | Yes |
pre-line | Collapsed | Kept | Yes |
break-spaces | Kept, and may wrap | Kept | Yes |
white-space-collapse
Whether runs of spaces, tabs and line breaks in the source collapse to a single space. preserve keeps them all; preserve-breaks keeps line breaks but collapses spaces; break-spaces keeps them and lets the line wrap after any space, so trailing spaces take up room.
| Syntax | collapse | discard | preserve | preserve-breaks | preserve-spaces | break-spaces |
|---|---|
| Initial | collapse |
| Applies to | Text |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 114 · Firefox 124 · Safari 17.4 |
| Spec | css-text-4 |
text-wrap
Shorthand for text-wrap-mode and text-wrap-style: whether lines wrap, and how the browser chooses where to break them.
| Syntax | <'text-wrap-mode'> || <'text-wrap-style'> |
|---|---|
| Initial | wrap |
| Applies to | See individual properties |
| Inherited | See individual properties |
| Percentages | See individual properties |
| Animation | See individual properties |
| Support | Chrome 114 · Firefox 121 · Safari 17.4 |
| Spec | css-text-4 |
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
text-wrap-mode
Whether text wraps onto new lines at all. nowrap keeps each line whole, letting it overflow its container.
| Syntax | wrap | nowrap |
|---|---|
| Initial | wrap |
| Applies to | Text |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 130 · Firefox 124 · Safari 17.4 |
| Spec | css-text-4 |
text-wrap-style
How the browser chooses line breaks in wrapping text.
| Syntax | auto | balance | stable | pretty | avoid-short-last-line |
|---|---|
| Initial | auto |
| Applies to | Block containers that establish an inline formatting context |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 130 · Firefox 124 · Safari 17.5 |
| Spec | css-text-4 |
| Value | Effect |
|---|---|
auto | The browser's fast default, filling each line in turn. |
balance | Lines are made roughly equal in length. Meant for headings and other short text; browsers limit it to a few lines. |
pretty | Slower, whole-paragraph line breaking that avoids very short last lines and uneven edges. Meant for body text. |
stable | Lines before the one being edited do not reflow, which suits editable text. |
overflow-wrap
Whether a word too long for its line may be broken at an arbitrary point to stop it overflowing, as long URLs often need. Its older name, word-wrap, still works as an alias.
| Syntax | normal | break-word | anywhere |
|---|---|
| Initial | normal |
| Applies to | Text |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 23 · Firefox 49 · Safari 7 |
| Spec | css-text-4 |
Both break-word and anywhere break a word only when there is no other way to fit it. The difference is sizing: anywhere counts those break points when working out the box's min-content width, so it also lets a shrink-to-fit box such as a flex item or table cell get narrower.
word-break
Where lines may break within words. Unlike overflow-wrap, it changes the break rules for all text, not just words that would overflow.
| Syntax | normal | break-all | keep-all | manual | auto-phrase | break-word |
|---|---|
| Initial | normal |
| Applies to | Text |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 15 · Safari 3 |
| Spec | css-text-4 |
| Value | Effect |
|---|---|
normal | The usual rules for each language. |
break-all | Lines may break between any two letters, as they do in Chinese and Japanese. |
keep-all | Lines may not break inside words in Chinese, Japanese or Korean text, only at spaces and punctuation. |
auto-phrase | Like keep-all, but breaks Japanese text between natural phrases. Chrome only; needs lang="ja". |
break-word | Legacy; the same as word-break: normal with overflow-wrap: anywhere. |
line-break
How strictly the line-breaking rules are applied, mainly for Chinese and Japanese, such as whether a line may begin with small kana or certain punctuation. anywhere allows a break between any two characters, even around punctuation.
| Syntax | auto | loose | normal | strict | anywhere |
|---|---|
| Initial | auto |
| Applies to | Text |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 58 · Firefox 69 · Safari 11 |
| Spec | css-text-4 |
hyphens
Whether words may be hyphenated at the end of a line. manual breaks only where the text contains a soft hyphen (­) or a real hyphen; auto also lets the browser hyphenate using a dictionary for the element's language; none never hyphenates.
| Syntax | none | manual | auto |
|---|---|
| Initial | manual |
| Applies to | Text |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 55 · Firefox 43 · Safari 17 |
| Spec | css-text-4 |
<html lang="en-GB">
article p { hyphens: auto; }
hyphenate-character
The string shown at the end of a line where a word is hyphenated. auto uses the right character for the language.
| Syntax | auto | <string> |
|---|---|
| Initial | auto |
| Applies to | Text |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 106 · Firefox 98 · Safari 17 |
| Spec | css-text-4 |
hyphenate-limit-chars
Limits automatic hyphenation by word length. Up to three values give the shortest word that may be hyphenated, the fewest characters before the break and the fewest after it.
| Syntax | [ auto | <integer [0,∞]> ]{1,3} |
|---|---|
| Initial | auto |
| Applies to | Text |
| Inherited | Yes |
| Animation | By computed value type |
| Support | Chrome 109 · Firefox 137 · Safari no |
| Spec | css-text-4 |
hyphenate-limit-chars: 8 3 3;
Transform & overflow
text-transform
Changes the case or form of characters for display, without changing the text in the document.
| Syntax | none | [capitalize | uppercase | lowercase ] || full-width || full-size-kana | math-auto |
|---|---|
| Initial | none |
| Applies to | Text |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 1 · Safari 1 |
| Spec | css-text-4 |
| Value | Effect |
|---|---|
uppercase / lowercase | All letters in capitals or in lower case, following the rules of the element's language. |
capitalize | The first letter of each word in capitals; the rest are left alone. |
full-width | Characters are replaced with their full-width forms, so Latin letters line up with ideographs. |
full-size-kana | Small Japanese kana are shown full size, which helps legibility in ruby. |
math-auto | Single-letter identifiers are shown in mathematical italic, as MathML's <mi> does. |
text-overflow
What is shown where inline content is clipped at the end of a line: clip cuts it off, ellipsis shows "…". It only applies when the line actually overflows a box whose overflow is not visible.
| Syntax | [ clip | ellipsis | <string> | fade | <fade()> ]{1,2} |
|---|---|
| Initial | clip |
| Applies to | Block containers |
| Inherited | No |
| Percentages | Refer to the width of the line box |
| Animation | By computed value type |
| Support | Chrome 1 · Firefox 7 · Safari 1.3 |
| Spec | css-overflow-4 |
.truncate {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
text-fit
Scales text up or down so that it fills the width of its container. grow enlarges text that is too narrow and shrink reduces text that is too wide; consistent applies one scale to every line, while per-line scales each line separately.
| Syntax | [ none | grow | shrink ] [consistent | per-line | per-line-all]? <percentage>? |
|---|---|
| Initial | none |
| Applies to | Block containers |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 150 · Firefox no · Safari no |
| Spec | css-text-5 |
Decoration
text-decoration
Shorthand for the line, thickness, style and colour of underlines, overlines and strike-throughs.
| Syntax | <'text-decoration-line'> || <'text-decoration-thickness'> || <'text-decoration-style'> || <'text-decoration-color'> |
|---|---|
| Initial | See individual properties |
| Applies to | See individual properties |
| Inherited | See individual properties |
| Percentages | See individual properties |
| Animation | See individual properties |
| Support | Chrome 1 · Firefox 1 · Safari 1 |
| Spec | css-text-decor-4 |
A decoration is drawn across all the text inside the element, including its descendants, and a descendant cannot remove it. Setting text-decoration: none on a child only stops the child adding its own. The early support versions cover the line keywords alone; the other parts arrived with each longhand.
a {
text-decoration: underline 0.08em;
text-underline-offset: 0.2em;
}
text-decoration-line
Which lines are drawn: underline, overline, line-through, or a combination. blink is accepted but browsers do not make text blink.
| Syntax | none | [ underline || overline || line-through || blink ] | spelling-error | grammar-error |
|---|---|
| Initial | none |
| Applies to | All elements |
| Inherited | No (but the lines are drawn across descendants' text) |
| Animation | Discrete |
| Support | Chrome 57 · Firefox 36 · Safari 12.1 |
| Spec | css-text-decor-4 |
text-decoration-style
The style of the decoration lines: a single solid line, a double line, dotted, dashed or wavy.
| Syntax | solid | double | dotted | dashed | wavy |
|---|---|
| Initial | solid |
| Applies to | All elements |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 57 · Firefox 36 · Safari 12.1 |
| Spec | css-text-decor-4 |
text-decoration-color
The colour of the decoration lines. By default they match the text colour.
| Syntax | <color> |
|---|---|
| Initial | currentcolor |
| Applies to | All elements |
| Inherited | No |
| Animation | By computed value type |
| Support | Chrome 57 · Firefox 36 · Safari 12.1 |
| Spec | css-text-decor-4 |
text-decoration-thickness
How thick the decoration lines are. from-font uses the thickness the font recommends; auto lets the browser choose. Lengths in em keep the line in proportion to the text.
| Syntax | auto | from-font | <length-percentage> | <line-width> |
|---|---|
| Initial | auto |
| Applies to | All elements |
| Inherited | No |
| Animation | By computed value |
| Support | Chrome 89 · Firefox 70 · Safari 12.1 |
| Spec | css-text-decor-4 |
text-decoration-skip-ink
Whether underlines and overlines break where they would cross a glyph, such as the descenders of g, j and y. none draws a continuous line through them.
| Syntax | auto | none | all |
|---|---|
| Initial | auto |
| Applies to | All elements |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 64 · Firefox 70 · Safari 15.4 |
| Spec | css-text-decor-4 |
text-decoration-skip-spaces
Whether decoration lines are drawn under spaces. The initial start end leaves out spaces at the start and end of the line; all skips every space; none draws under them all.
| Syntax | none | all | [ start || end ] |
|---|---|
| Initial | start end |
| Applies to | All elements |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 155 · Firefox no · Safari no |
| Spec | css-text-decor-4 |
text-decoration-skip Deprecated
An older shorthand for which parts of the content decoration lines skip. Use text-decoration-skip-ink to control skipping around glyphs instead.
| Syntax | none | auto |
|---|---|
| Initial | See individual properties |
| Applies to | All elements |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 57 to 63 (removed in 64) · Firefox no · Safari 12.1 |
| Spec | css-text-decor-4 |
text-decoration-inset
Shortens or lengthens the decoration line at its start and end. Positive values pull the ends in; negative values extend the line past the text. One value sets both ends; two set start then end.
| Syntax | <length-percentage>{1,2} | auto |
|---|---|
| Initial | 0 |
| Applies to | All elements |
| Inherited | No |
| Percentages | Refer to the inline size of the decorating box, or of each box fragment, depending on box-decoration-break |
| Animation | By computed value |
| Support | Chrome 157 · Firefox 146 · Safari no |
| Spec | css-text-decor-4 |
text-underline-offset
Moves the underline away from its default position: positive values move it further from the text. Unlike the decoration longhands, it is inherited, so it can be set once on a container.
| Syntax | auto | <length-percentage> |
|---|---|
| Initial | auto |
| Applies to | All elements |
| Inherited | Yes |
| Animation | By computed value |
| Support | Chrome 87 · Firefox 70 · Safari 12.1 |
| Spec | css-text-decor-4 |
text-underline-position
Where the underline sits. from-font uses the position the font recommends; under puts it below the descenders, which keeps it clear of subscripts in chemical and mathematical text. left and right choose the side in vertical text.
| Syntax | auto | [ from-font | under ] || [ left | right ] |
|---|---|
| Initial | auto |
| Applies to | All elements |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 33 · Firefox 74 · Safari 12.1 |
| Spec | css-text-decor-4 |
text-shadow
One or more shadows drawn behind the text, each with a horizontal and vertical offset, an optional blur radius and a colour. The first shadow in the list is drawn on top.
| Syntax | none | <shadow># |
|---|---|
| Initial | none |
| Applies to | Text |
| Inherited | Yes |
| Animation | As shadow list |
| Support | Chrome 2 · Firefox 3.5 · Safari 1.1 |
| Spec | css-text-decor-4 |
text-shadow: 0 1px 2px rgb(0 0 0 / 0.4);
Emphasis marks
text-emphasis
Shorthand for text-emphasis-style and text-emphasis-color: small marks drawn beside each character to emphasise it, the usual way to stress text in Chinese and Japanese. Their position is set separately with text-emphasis-position.
| Syntax | <'text-emphasis-style'> || <'text-emphasis-color'> |
|---|---|
| Initial | See individual properties |
| Applies to | See individual properties |
| Inherited | See individual properties |
| Percentages | See individual properties |
| Animation | See individual properties |
| Support | Chrome 99 · Firefox 46 · Safari 7 |
| Spec | css-text-decor-4 |
em:lang(ja) { font-style: normal; text-emphasis: filled sesame; }
text-emphasis-style
The shape of the emphasis marks: dot, circle, double-circle, triangle or sesame, each filled or open, or any single character given as a string.
| Syntax | none | [ [ filled | open ] || [ dot | circle | double-circle | triangle | sesame ] ] | <string> |
|---|---|
| Initial | none |
| Applies to | Text |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 99 · Firefox 46 · Safari 7 |
| Spec | css-text-decor-4 |
text-emphasis-color
The colour of the emphasis marks. By default they match the text colour.
| Syntax | <color> |
|---|---|
| Initial | currentcolor |
| Applies to | Text |
| Inherited | Yes |
| Animation | By computed value type |
| Support | Chrome 99 · Firefox 46 · Safari 7 |
| Spec | css-text-decor-4 |
text-emphasis-position
Which side of the text the emphasis marks go on: over or under in horizontal text, and right or left in vertical text. Japanese usually places them over; Chinese usually under.
| Syntax | [ over | under ] && [ right | left ]? |
|---|---|
| Initial | over right |
| Applies to | Text |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 99 · Firefox 46 · Safari 7 |
| Spec | css-text-decor-4 |
Inline layout
line-height
The height of each line box, which spaces the lines of text. On a block it sets the minimum height of its lines; on an inline box it sets the height that box contributes.
| Syntax | normal | <number [0,∞]> | <length-percentage [0,∞]> |
|---|---|
| Initial | normal |
| Applies to | Non-replaced inline boxes and SVG text content elements |
| Inherited | Yes |
| Percentages | Relative to the element's font size |
| Animation | By computed value type |
| Support | Chrome 1 · Firefox 1 · Safari 1 |
| Spec | css-inline-3 |
Prefer a unitless number. It is inherited as a factor, so each descendant recalculates it from its own font size; a length or percentage is inherited as a fixed length and can be too tight for larger text.
body { line-height: 1.5; }
vertical-align
Shorthand for alignment-baseline, baseline-shift and baseline-source: how an inline-level box sits within its line, or how a table cell's content is aligned within the cell.
| Syntax | [ first | last] || <'alignment-baseline'> || <'baseline-shift'> |
|---|---|
| Initial | baseline |
| Applies to | See individual properties |
| Inherited | No |
| Animation | See individual properties |
| Support | Chrome 1 · Firefox 1 · Safari 1 |
| Spec | css-inline-3 |
| Value | Effect |
|---|---|
baseline | The box's baseline lines up with its parent's. |
sub / super | Lowered or raised to the subscript or superscript position. |
middle | The middle of the box lines up with the parent's baseline plus half its x-height. |
text-top / text-bottom | Aligned to the top or bottom of the parent's font. |
top / bottom | Aligned to the top or bottom of the whole line box. |
<length-percentage> | Raised by that amount (lowered if negative); percentages refer to line-height. |
In a table cell, top, middle and bottom align the cell's content vertically. It has no effect on block-level boxes; use flexbox or grid alignment for those.
dominant-baseline
Which baseline a box uses to align the text and inline boxes inside it, such as alphabetic for Latin text, ideographic for Chinese and Japanese, hanging for scripts like Devanagari, or central. It is mostly used on SVG text.
| Syntax | auto | <baseline-metric> |
|---|---|
| Initial | auto |
| Applies to | Block containers, inline boxes, table rows, grid containers, flex containers and SVG text content elements |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 1 · Safari 4 |
| Spec | css-inline-3 |
<baseline-metric> is one of text-bottom, alphabetic, ideographic, middle, central, mathematical, hanging or text-top.
alignment-baseline
Which of a box's baselines is lined up with the matching baseline of its parent. Like dominant-baseline, it is mostly used on SVG text; in HTML, vertical-align sets it.
| Syntax | baseline | <baseline-metric> |
|---|---|
| Initial | baseline |
| Applies to | Inline-level boxes, flex items, grid items, table cells and SVG text content elements |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 149 · Safari 5.1 |
| Spec | css-inline-3 |
baseline-shift
Raises or lowers a box from its aligned position. Positive lengths raise it; sub and super move it to the subscript or superscript position.
| Syntax | <length-percentage> | sub | super | top | center | bottom |
|---|---|
| Initial | 0 |
| Applies to | Inline-level boxes and SVG text content elements |
| Inherited | No |
| Percentages | Refer to the used value of line-height |
| Animation | By computed value type |
| Support | Chrome 1 · Firefox 149 · Safari 4 |
| Spec | css-inline-3 |
baseline-source
Whether an inline-level box with several lines aligns by its first or last line's baseline. auto uses the last baseline for inline blocks and the first for everything else, which is why a multi-line inline block sits by its bottom line.
| Syntax | auto | first | last |
|---|---|
| Initial | auto |
| Applies to | Inline-level boxes that establish an independent formatting context |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 111 · Firefox 115 · Safari no |
| Spec | css-inline-3 |
text-box
Shorthand for text-box-trim and text-box-edge: trims the space a font reserves above and below its letters, so that text can be aligned to its cap height or baseline instead of to the edges of the line box.
| Syntax | normal | <'text-box-trim'> || <'text-box-edge'> |
|---|---|
| Initial | normal |
| Applies to | Block containers, multi-column containers and inline boxes |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 133 · Firefox 154 · Safari 18.2 |
| Spec | css-inline-3 |
.button { text-box: trim-both cap alphabetic; }
text-box-trim
Which sides are trimmed: trim-start trims above the first line, trim-end below the last line, and trim-both both.
| Syntax | none | trim-start | trim-end | trim-both |
|---|---|
| Initial | none |
| Applies to | Block containers, multi-column containers and inline boxes |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 133 · Firefox 154 · Safari 18.2 |
| Spec | css-inline-3 |
text-box-edge
Which font metrics the trim cuts to. The first keyword is the top edge (text, cap, ex, ideographic or ideographic-ink) and the second the bottom edge (text, alphabetic, ideographic or ideographic-ink).
| Syntax | auto | <text-edge> |
|---|---|
| Initial | auto |
| Applies to | Block containers and inline boxes |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 133 · Firefox 154 · Safari 18.2 |
| Spec | css-inline-3 |
A single keyword such as text or ideographic sets both edges.
initial-letter
Makes a drop cap or raised initial. The first number is the letter's size in lines of text; the optional second is how many lines it sinks into the paragraph.
| Syntax | normal | <number [1,∞]> <integer [1,∞]> | <number [1,∞]> && [ drop | raise ]? |
|---|---|
| Initial | normal |
| Applies to | ::first-letter, inline-level boxes at the start of a block and inside ::marker boxes (see the spec) |
| Inherited | No |
| Animation | By computed value type |
| Support | Chrome 110 · Firefox no · Safari no |
| Spec | css-inline-3 |
p:first-of-type::first-letter { initial-letter: 3; }
Safari supports it only with the -webkit- prefix.
Ruby
ruby-position
Where ruby annotations (the small reading aids set beside East Asian text) are placed: over puts them above horizontal text, under below it. alternate, the initial value, places a single annotation over and alternates sides when there are two levels.
| Syntax | [ alternate || [ over | under ] ] | inter-character |
|---|---|
| Initial | alternate |
| Applies to | Ruby annotation containers |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 84 · Firefox 38 · Safari 18.2 |
| Spec | css-ruby-1 |
rt { ruby-position: under; }
ruby-align
How ruby text is spread across its base, or a base across its annotation, when one is shorter than the other: at the start, in the center, or with the spare space distributed by space-between or space-around.
| Syntax | start | center | space-between | space-around |
|---|---|
| Initial | space-around |
| Applies to | Ruby bases, ruby annotations, ruby base containers and ruby annotation containers |
| Inherited | Yes |
| Animation | By computed value type |
| Support | Chrome 128 · Firefox 38 · Safari 18.2 |
| Spec | css-ruby-1 |
ruby-overhang
Whether a ruby annotation wider than its base may hang over the neighbouring text instead of pushing it apart.
| Syntax | auto | spaces |
|---|---|
| Initial | auto |
| Applies to | Ruby annotation containers |
| Inherited | Yes |
| Animation | By computed value type |
| Support | Chrome 151 · Firefox no · Safari 18.2 |
| Spec | css-ruby-1 |
Math layout
math-depth
The nesting depth of an element within a MathML formula, which font-size: math uses to make scripts and nested fractions progressively smaller. auto-add adds one when the parent's math-style is compact; add() adds a given amount; an integer sets the depth outright.
| Syntax | auto-add | add(<integer>) | <integer> |
|---|---|
| Initial | 0 |
| Applies to | All elements |
| Inherited | Yes |
| Animation | By computed value type |
| Support | Chrome 109 · Firefox 117 · Safari 26.4 |
| Spec | mathml-core |
The browser's MathML style sheet already sets it on scripts, so you rarely need to set it yourself.
math-shift
How high superscripts are raised in MathML. compact uses a smaller shift, as in denominators and under radicals, where space is tight.
| Syntax | normal | compact |
|---|---|
| Initial | normal |
| Applies to | All elements |
| Inherited | Yes |
| Animation | By computed value type |
| Support | Chrome 109 · Firefox 146 · Safari 26.2 |
| Spec | mathml-core |
math-style
Whether a MathML formula is laid out in display style (normal), with full-size operators and limits above and below, or in the more compact inline style (compact) that fits within a line of text.
| Syntax | normal | compact |
|---|---|
| Initial | normal |
| Applies to | All elements |
| Inherited | Yes |
| Animation | By computed value type |
| Support | Chrome 109 · Firefox 117 · Safari 14.1 |
| Spec | mathml-core |
Text size adjustment
text-size-adjust
Controls the automatic enlargement of text that some mobile browsers apply to pages not designed for small screens. none turns it off; a percentage sets the enlargement factor.
| Syntax | auto | none | <percentage [0,∞]> |
|---|---|
| Initial | auto |
| Applies to | All elements |
| Inherited | Yes |
| Percentages | The percentage itself is the adjustment factor for the font size |
| Animation | By computed value |
| Support | Chrome 54 · Firefox no · Safari no |
| Spec | css-size-adjust-1 |
Safari on iOS supports it with the -webkit- prefix. A page with a proper <meta name="viewport"> tag is not enlarged in the first place.
Compatibility (-webkit-) properties
These prefixed properties began in WebKit, but so much of the web depends on them that every browser now supports them, and the Compat Standard defines them.
-webkit-line-clamp
Cuts a block's content off after a given number of lines and puts an ellipsis at the end of the last one. It only works together with display: -webkit-box and -webkit-box-orient: vertical, and usually overflow: hidden.
| Syntax | none | <integer [1,∞]> |
|---|---|
| Initial | none |
| Applies to | See individual properties |
| Inherited | See individual properties |
| Animation | See individual properties |
| Support | Chrome 6 · Firefox 68 · Safari 5 |
| Spec | compat |
.summary {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
}
-webkit-text-fill-color
The colour used to fill the glyphs of text, overriding color for the fill only. Setting it to transparent together with background-clip: text lets a gradient or image show through the letters.
| Syntax | <color> |
|---|---|
| Initial | currentcolor |
| Applies to | All elements |
| Inherited | Yes |
| Animation | By computed value type |
| Support | Chrome 1 · Firefox 49 · Safari 3 |
| Spec | compat |
h1 {
background: linear-gradient(90deg, teal, purple);
background-clip: text;
-webkit-text-fill-color: transparent;
}
-webkit-text-stroke
Shorthand for -webkit-text-stroke-width and -webkit-text-stroke-color: an outline drawn along the edges of each glyph.
| Syntax | <line-width> || <color> |
|---|---|
| Initial | See individual properties |
| Applies to | See individual properties |
| Inherited | Yes |
| Animation | See individual properties |
| Support | Chrome 4 · Firefox 49 · Safari 3 |
| Spec | compat |
The stroke is centred on the glyph outline, so a thick stroke eats into the letter's fill as well as growing outwards.
-webkit-text-stroke: 1px currentcolor;
-webkit-text-fill-color: transparent;
-webkit-text-stroke-width
The width of the outline drawn around text. <line-width> is a non-negative length or one of thin, medium and thick.
| Syntax | <line-width> |
|---|---|
| Initial | 0 |
| Applies to | All elements |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 49 · Safari 3 |
| Spec | compat |
-webkit-text-stroke-color
The colour of the outline drawn around text. By default it matches the text colour.
| Syntax | <color> |
|---|---|
| Initial | currentcolor |
| Applies to | All elements |
| Inherited | Yes |
| Animation | By computed value type |
| Support | Chrome 1 · Firefox 49 · Safari 3 |
| Spec | compat |