Lists, tables & content

The properties that style list markers, keep counters, insert generated content and control table layout. Custom marker styles are defined with @counter-style; display: table and the other table display types are under Box model.

Lists

list-style

Shorthand for list-style-type, list-style-position and list-style-image, in any order.

Syntax<'list-style-position'> || <'list-style-image'> || <'list-style-type'>
InitialSee individual properties
Applies toList items
InheritedSee individual properties
PercentagesSee individual properties
AnimationSee individual properties
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-lists-3

list-style: none sets both the type and the image to none, removing the markers. Safari with VoiceOver then stops announcing the element as a list; add role="list" to the <ul> or <ol> if that matters.

ul.plain { list-style: none; padding-inline-start: 0; }
A bare list for navigation or cards: no markers and no indent.

list-style-type

The marker drawn for each list item. A <counter-style> is a built-in style name (disc, circle, square, decimal, lower-roman, upper-alpha …) or one defined with @counter-style; a <string> is used as the marker exactly as written.

Syntax<counter-style> | <string> | none
Initialdisc
Applies toList items
InheritedYes
AnimationDiscrete
SupportChrome 1 · Firefox 1 · Safari 1
<string> values: Chrome 79 · Firefox 39 · Safari 14.1
Speccss-lists-3
ol { list-style-type: lower-roman; }
ul.steps { list-style-type: '→ '; }
A counter style by name, and a fixed string marker.

list-style-position

Whether the marker sits outside the list item's box, in the margin, or inside it as the first inline content, so that wrapped lines run under the marker.

Syntaxinside | outside
Initialoutside
Applies toList items
InheritedYes
AnimationDiscrete
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-lists-3

list-style-image

An image to use as the marker instead of the list-style-type marker. If the image cannot be loaded, the list-style-type marker is shown.

Syntax<image> | none
Initialnone
Applies toList items
InheritedYes
AnimationDiscrete
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-lists-3

The image is drawn at its natural size. For control over size and alignment, style the ::marker pseudo-element or use a background image instead.

Counters

counter-reset

Creates one or more new counters on the element, each starting at the given integer (0 if omitted). Descendants and later siblings see the new counter, and the counter() and counters() functions print its value in content.

Syntax[ <counter-name> <integer>? | <reversed-counter-name> <integer>? ]+ | none
Initialnone
Applies toAll elements
InheritedNo
AnimationBy computed value type
SupportChrome 2 · Firefox 1 · Safari 3
reversed(): Chrome no · Firefox 96 · Safari no
Speccss-lists-3

A <reversed-counter-name> is reversed(name): a counter that counts down, starting by default from the number of items. List items use a built-in counter called list-item, which these properties can also reset and change.

article { counter-reset: figure; }
figure { counter-increment: figure; }
figcaption::before { content: 'Figure ' counter(figure) ': '; }
Number the figures in each article automatically.

counter-increment

Adds to one or more counters each time the element appears. The integer is the step (1 if omitted) and can be negative. If no counter of that name is in scope, a new one is created at 0 first.

Syntax[ <counter-name> <integer>? ]+ | none
Initialnone
Applies toAll elements
InheritedNo
AnimationBy computed value type
SupportChrome 2 · Firefox 1 · Safari 3
Speccss-lists-3

counter-set

Sets one or more existing counters to a value (0 if omitted) without starting a new counter, so nested numbering is not affected.

Syntax[ <counter-name> <integer>? ]+ | none
Initialnone
Applies toAll elements
InheritedNo
AnimationBy computed value type
SupportChrome 85 · Firefox 68 · Safari 17.2
Speccss-lists-3

On one element, counters are reset first, then set, then incremented.

Generated content

content

The content generated for ::before, ::after and ::marker, or a replacement for an element's own content. A <content-list> is a run of strings, images, counter(), counters(), attr() and the quote keywords open-quote, close-quote, no-open-quote and no-close-quote.

Syntaxnormal | none | [ <content-replacement> | <content-list> ] [/ <alt-text> ]? | <element()>
Initialnormal
Applies toAll elements, tree-abiding pseudo-elements and page margin boxes
InheritedNo
AnimationDiscrete
SupportChrome 1 · Firefox 1 · Safari 1
<content-replacement>: Chrome 28 · Firefox 63 · Safari 9
/ <alt-text>: Chrome 77 · Firefox 128 · Safari 17.4
Speccss-content-3
ValueEffect
normalOn ::before and ::after this means no box; on an element, its usual content.
noneNo generated content; the pseudo-element is not created.
<content-list>The listed strings, images, counters and attribute values, run together as inline content.
<content-replacement>A single <image> that replaces the element's content, making it behave like a replaced element.
/ <alt-text>Strings or counters giving the text that assistive technology reads in place of the generated content. An empty string marks it as decorative.
a[target=_blank]::after { content: ' ↗' / ' (opens in a new tab)'; }
A visual arrow, with a spoken description for screen readers.

quotes

The quotation marks that open-quote and close-quote insert, for example around <q> elements. Each pair of strings is one nesting level: the first pair for outer quotes, the next for quotes inside them.

Syntaxauto | none | [ <string> <string> ]+
Initialauto
Applies toAll elements
InheritedYes
AnimationDiscrete
SupportChrome 11 · Firefox 1.5 · Safari 9
auto: Chrome 87 · Firefox 70 · Safari 14.1
Speccss-content-3

auto picks marks suited to the content language set by lang. none makes the quote keywords insert nothing.

q { quotes: '«' '»' '‹' '›'; }
Guillemets for outer quotes, single guillemets for quotes inside them.

Tables

border-collapse

Chooses between the separated borders model, where each cell has its own border with space between, and the collapsing model, where adjacent cells share a single border.

Syntaxseparate | collapse
Initialseparate
Applies toTable grid boxes
InheritedYes
AnimationDiscrete
SupportChrome 1 · Firefox 1 · Safari 1.1
Speccss-tables-3

In the collapsing model, where two borders meet the wider one wins, and border-spacing and empty-cells have no effect.

table { border-collapse: collapse; }
td, th { border: 1px solid; }
Single 1px grid lines between cells instead of doubled borders.

border-spacing

The gap between the borders of adjacent cells in the separated borders model. One length sets both directions; two set the horizontal then the vertical gap.

Syntax<length [0,∞]>{1,2}
Initial0px 0px
Applies toTable grid boxes when border-collapse is separate
InheritedYes
AnimationBy computed value
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-tables-3

Browsers' default style sheets give HTML tables border-spacing: 2px.

caption-side

Puts a table's caption above or below the table.

Syntaxtop | bottom
Initialtop
Applies toTable caption boxes
InheritedYes
AnimationDiscrete
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-tables-3

empty-cells

Whether borders and backgrounds are drawn around cells that have no visible content, in the separated borders model.

Syntaxshow | hide
Initialshow
Applies toTable cell boxes
InheritedYes
AnimationDiscrete
SupportChrome 1 · Firefox 1 · Safari 1.2
Speccss-tables-3

table-layout

Chooses how column widths are worked out. auto sizes columns to fit the content of every cell. fixed takes the widths from the table and its first row only, so the table lays out faster and long content cannot widen a column.

Syntaxauto | fixed
Initialauto
Applies toTable grid boxes
InheritedNo
AnimationDiscrete
SupportChrome 14 · Firefox 1 · Safari 1
Speccss-tables-3
table { table-layout: fixed; width: 100%; }
col.name { width: 40%; }
Fixed layout needs a width on the table; column widths then come from <col> or the first row.