Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

CSS shorthand `list-style`

`list-style` sets a list item’s marker type, position, and optional image in one declaration.

Version: CSS modules; captured CSSWG editor index includes draft and obsolete features requiring review

Syntax

<'list-style-type'> || <'list-style-position'> || <'list-style-image'>

list-style sets a list item’s marker type, position, and optional image in one declaration.

The example starts with a marker image, outside position, and disc type; applying square inside changes two components and resets the omitted image to none.

Grammar: <'list-style-type'> || <'list-style-position'> || <'list-style-image'>.

A component omitted from the shorthand returns to its initial value rather than retaining an earlier declaration. The shorthand affects elements that generate a list marker; the properties accepted directly by ::marker are a separate, limited set.

Examples

<!doctype html>
<html lang="en"><meta charset="utf-8"><title>list-style behavior</title>
<body><ul><li id="item">entry</li></ul><pre id="result"></pre><script>
const item=document.querySelector('#item');item.style.cssText='list-style-type:disc;list-style-position:outside;list-style-image:linear-gradient(red,red)';
item.style.listStyle='square inside';const style=getComputedStyle(item);
document.querySelector('#result').textContent='type='+style.listStyleType+'; position='+style.listStylePosition+'; image='+style.listStyleImage+'; marker='+getComputedStyle(item,'::marker').display;
</script></body></html>

Result

type=square; position=inside; image=none; marker=inline

The example was executed locally in an isolated, network-free Chrome session; the result comes from the browser CSS API.

Sources