CSS reference with playgrounds
Learn CSS by playing with it.
Drag a slider and the preview and code change together. Edit the code and the controls follow along. A reference for getting a hands-on feel for how CSS actually behaves.
Move it, see it
Change a value and watch the preview and code update instantly.
Write it, check it
Edit the code directly and the controls move along with it.
Share the exact state
Everything you change lives in the URL, so a link opens the same view.
Stack blocks, mix properties
Stack properties like blocks and they all apply to the same box. Open a block to tweak it with the same controls as its reference page.
Preview
Code
.box {
border-radius: 48px 8px;
background: linear-gradient(
135deg,
#88d1c7 0%,
#77a7d7,
#eaac3a 100%
);
box-shadow: 0 1px 2px #0f172a1f, 0 16px 40px -8px #0f172a40;
}Blocks3
- border-radiusSame radius for every cornerElliptical corners (vertical radii after /)top-left48pxtop-right8pxbottom-right48pxbottom-left8px
- linear-gradient()repeating-direction135degcolor-stop-list
Drag the markers to move stops
#88d1c7 0%ColorPositionSecond position#77a7d7Color hint (midpoint from previous)ColorPosition#eaac3a 100%Color hint (midpoint from previous)ColorPositionSecond position - Shadow 1insetoffset-xoffset-yblur-radiusspread-radiuscolorShadow 2insetoffset-xoffset-yblur-radiusspread-radiuscolor
Box
Size
Spacing & overflow
Layout
Display type
Flexbox
Grid
Alignment & gaps
Floats
Positioning
Stacking order
Multi-column
Background
Color & blending
Gradients
Size, position & area
Border
Effects
Shadows, filters & blending
Opacity & visibility
Clipping & masking
Transform
Images
Fonts
Typeface, size & line height
Weight & style
Glyph variants
Text styling
Text color
Lines, shadows & strokes
Emphasis marks
Ruby
Quotation marks
Spacing & case
Paragraphs & wrapping
Alignment & indent
Line breaking & wrapping
Truncation
Text box trimming
Lists
Tables
Writing modes
Interaction
Pointer and selection
Form controls and color scheme
Scrolling
background blocks stack as layers (higher blocks are drawn on top). Other properties take one block each.
Properties176
Each comes with notes on defaults and gotchas, plus links to MDN and the spec.
Box15
Size10
Width and height, their limits, and aspect ratio
width
width: 160px;
width sets the width of an element. Besides fixed lengths, you can use % of the parent or keywords that size the element from its content.
min-width
min-width: 200px;
min-width sets a lower limit on the width of an element. Even when width, the parent, or the content would make it narrower, it never gets narrower than min-width.
max-width
max-width: 320px;
max-width sets an upper limit on the width of an element. Even a box that stretches with its parent, like width: 100%, never gets wider than max-width. It is a staple of layouts that adapt to the screen width.
height
height: 64px;
height sets the height of an element. With the initial auto it grows and shrinks with the content; with a length it stays that tall however much content there is.
min-height
min-height: 12em;
min-height sets a lower limit on the height of an element. It keeps that height even with little content and grows taller when there is more, so it holds up better than a fixed height.
max-height
max-height: 5em;
max-height sets an upper limit on the height of an element. It fits the content while there is little of it, and never gets taller than the limit when there is more. It is often paired with overflow to make long content scroll.
inline-size
inline-size: 120px;
inline-size sets the size of an element in the direction its text runs. In horizontal text it works like width, and in vertical text like height.
block-size
block-size: 200px;
block-size sets the size of an element in the direction its lines stack. In horizontal text it works like height, and in vertical text like width.
aspect-ratio
aspect-ratio: 16 / 9;
aspect-ratio sets the ratio of a box's width to its height. Set only the width and the height follows the ratio. Handy for embedded videos and square thumbnails.
box-sizing
box-sizing: border-box;
box-sizing decides whether width and height include padding and border. With border-box, the box is exactly the width and height you set.
Spacing & overflow5
Space inside and outside the box, and what happens when content overflows
padding
padding: 16px 40px;
padding sets the space between a box's border and its content (the inner spacing). The background color also fills the padding.
margin
margin: 24px 48px;
margin sets the space outside a box's border (the outer spacing). It separates the box from its neighbors, and auto can center it.
overflow
overflow: visible;
overflow decides what to show when the content does not fit in the box: let it spill out, clip it away, or make it scrollable.
scrollbar-width
scrollbar-width: thin;
scrollbar-width makes scrollbars thinner or hides them. You pick the thickness with a keyword; pixel values are not allowed.
scrollbar-color
scrollbar-color: #4a86cb #e6f2f0;
scrollbar-color sets the colors of the scrollbar thumb (the part you drag) and the track (the part it moves along).
Layout43Grid overview →
Display type1
Whether an element is a block or sits in a line, and whether its contents use flex or grid
Flexbox6
Written on a display: flex box or on the items inside it
flex-direction
flex-direction: column;
flex-direction sets whether the items in a flexbox run across (row) or down (column), and which end they start from.
flex-wrap
flex-wrap: wrap;
flex-wrap sets whether flexbox items that do not fit on one line wrap onto the next line.
flex-grow
flex-grow: 1;
flex-grow goes on a flex item and sets how much of the leftover width (or height, in a column) of the container the item takes to grow.
flex-shrink
flex-shrink: 0;
flex-shrink goes on a flex item and sets how much the item shrinks when the items don't fit in the container.
flex-basis
flex-basis: 50%;
flex-basis goes on a flex item and sets its base size (its width, in a row) before leftover space is shared out by flex-grow or overflow is taken off by flex-shrink.
order
order: -1;
order goes on a flex or grid item and changes the order the items are laid out in, away from their order in the HTML.
Grid8
Make columns and rows in a display: grid box and place items in the cells
grid-template-columns
grid-template-columns: 60px 1fr 2fr;
grid-template-columns sets how many columns a grid container has and how wide each one is. Write the column sizes (tracks) in order, separated by spaces.
grid-template-rows
grid-template-rows: 1fr 2fr;
grid-template-rows sets how many rows a grid container has and how tall each one is. It works like grid-template-columns: write the row sizes (tracks) from top to bottom.
grid-auto-rows
grid-auto-rows: 40px 1fr;
grid-auto-rows sets the height of rows that grid-template-rows does not set, that is, the rows added automatically to fit the items.
grid-auto-columns
grid-auto-columns: 40px 1fr;
grid-auto-columns sets the width of columns that grid-template-columns does not set, that is, the columns added automatically to fit the items.
grid-auto-flow
grid-auto-flow: row dense;
grid-auto-flow sets whether grid items without a set position are placed along the rows or down the columns, and whether earlier empty cells get filled in.
grid-column
grid-column: span 2;
grid-column goes on a grid item and sets which columns it sits in and how many columns it spans. It is a shorthand for grid-column-start and grid-column-end.
grid-row
grid-row: span 2;
grid-row goes on a grid item and sets which rows it sits in and how many rows it spans. It is a shorthand for grid-row-start and grid-row-end.
grid-area
grid-area: 1 / 2 / 3 / 4;
grid-area goes on a grid item and sets the rows and columns it sits in at once. It is a shorthand for grid-row-start, grid-column-start, grid-row-end and grid-column-end.
Alignment & gaps10
Alignment and gaps that work in both flex and grid
justify-content
justify-content: space-between;
justify-content sets where items in a flexbox or grid sit along the main axis (the direction they run in) and how leftover space is shared.
align-items
align-items: center;
align-items sets where items in a flexbox or grid line up along the cross axis (across the direction they run in). In a flexbox running across, that is the vertical alignment.
align-content
align-content: center;
align-content sets where the wrapped lines of a flexbox, or the rows of a grid, sit as a group along the cross axis (vertically when items run across) and how leftover space is shared.
gap
gap: 16px 8px;
gap sets the space between rows (row-gap) and between columns (column-gap) of items in a flexbox, grid or multi-column layout.
justify-items
justify-items: center;
justify-items sets where grid items sit inside their cells along the inline axis (left to right in horizontal text), for all items at once.
place-items
place-items: center;
place-items is a shorthand for align-items (vertical position) and justify-items (horizontal position). place-items: center puts grid items in the middle of their cells both ways.
place-content
place-content: center;
place-content is a shorthand for align-content (vertical position of the rows as a group) and justify-content (horizontal position of the columns as a group). It decides where the content as a whole goes in the space left over in the box.
align-self
align-self: center;
align-self goes on a single flex or grid item and gives it a different position on the cross axis (vertical, for a row) from the align-items of its container.
justify-self
justify-self: center;
justify-self goes on a single grid item and sets where that item sits inside its cell along the inline axis (left to right in horizontal text). It overrides the justify-items of the container for that item.
place-self
place-self: center;
place-self is a shorthand for align-self (vertical position) and justify-self (horizontal position). It goes on a single grid item and moves just that item inside its cell.
Floats5
Push an element to one side and let text wrap around it
float
float: left;
float pushes an element to the left or right end of the line and lets the following text wrap around it.
clear
clear: left;
clear moves an element down below earlier floated elements instead of letting it sit beside them.
shape-outside
shape-outside: circle(closest-side);
shape-outside sets the shape that text flows around next to a floated element. It lets text follow circles, polygons, or the opaque parts of an image instead of a rectangle.
shape-margin
shape-margin: 1em;
shape-margin adds space around the shape set by shape-outside, keeping the text that flows around it farther away.
shape-image-threshold
shape-image-threshold: 0.5;
shape-image-threshold sets, as a number from 0 to 1, how opaque a part of a shape-outside image must be to count as part of the shape.
Positioning2
Shift an element from its normal place or pin it somewhere
position
position: absolute;
position sets whether an element stays in the normal flow, is nudged from there, or is taken out of the flow and placed where you choose. The place is set with top, right, bottom and left.
inset
inset: 16px 16px auto auto;
inset is a shorthand that sets top, right, bottom and left together on a positioned element (one whose position is not static).
Stacking order1
Which element comes to the front when they overlap
Multi-column10
Flow text into several columns like a newspaper
column-count
column-count: 2;
column-count sets how many columns the text in a box flows into (multi-column layout). As in a newspaper, the text continues at the top of the second column after reaching the bottom of the first.
column-width
column-width: 6em;
column-width sets the ideal width of columns in a multi-column layout. The box gets as many columns as fit, so the number of columns follows the box width without media queries.
column-rule
column-rule: 2px solid #88d1c7;
column-rule sets the line drawn between the columns of a multi-column layout. It is a shorthand for column-rule-width, column-rule-style and column-rule-color.
column-fill
column-fill: auto;
column-fill sets whether text in a multi-column layout is split so the columns are the same height, or fills the columns one after another.
column-span
column-span: all;
column-span sets whether an element inside a multi-column layout spans all the columns, running the full width.
break-inside
break-inside: avoid;
break-inside sets whether an element may be split at a column break or a printed page break. With avoid, it is moved to the next column or page instead when possible.
break-before
break-before: column;
break-before sets whether a column or page break happens just before an element. With column, the element starts at the top of the next column.
break-after
break-after: column;
break-after sets whether a column or page break happens just after an element. With column, whatever follows the element starts at the top of the next column.
orphans
orphans: 3;
orphans sets the minimum number of lines of a paragraph to leave before a column or page break (at the bottom of the column or page). If that many lines do not fit, the whole paragraph moves to the next column or page.
widows
widows: 3;
widows sets the minimum number of lines of a paragraph to carry over after a column or page break (at the top of the next column or page). If there would be fewer, more lines are moved from the previous column.
Background11
Color & blending2
The background color and how background layers blend
background-color
background-color: #88d1c7;
background-color sets the background color of an element. When there is a background image or gradient, the color is painted underneath it.
background-blend-mode
background-blend-mode: multiply;
background-blend-mode sets how background images mix with each other and with the background color, so a single element’s background can tint a photo.
Gradients3
Backgrounds whose colors change smoothly
linear-gradient()
background: linear-gradient(135deg, #88d1c7 0%, #77a7d7, #eaac3a 100%);
linear-gradient() creates an image of two or more colors transitioning along a straight line. Use it with properties that accept an image, such as background or background-image.
radial-gradient()
background: radial-gradient(circle at 30% 30%, #88d1c7, #77a7d7 50%, #eaac3a);
radial-gradient() creates an image of colors spreading outward from a center as a circle or an ellipse. Use it with properties that accept an image, such as background or background-image.
conic-gradient()
background: conic-gradient(from 45deg, #88d1c7, #77a7d7, #eaac3a, #88d1c7);
conic-gradient() creates an image whose colors change as you sweep around a center, like the hand of a clock. It draws pie charts and color wheels.
Size, position & area6
Size, position, repetition, and scrolling of background images, and how far they paint
background-size
background-size: 50%;
background-size sets how large a background image is drawn. Give a width and height directly, or use cover and contain to fit the element.
background-repeat
background-repeat: space;
background-repeat sets whether a background image is tiled and how the tiles are laid out. The initial value, repeat, tiles it like wallpaper and cuts off the images that don’t fit at the edges.
background-position
background-position: 25% 75%;
background-position sets where a background image sits. Write the horizontal then the vertical position with keywords, lengths or percentages.
background-attachment
background-attachment: local;
background-attachment sets whether a background image is placed against the element’s border, its contents, or the viewport, and so how it moves when you scroll.
background-clip
background-clip: text;
background-clip sets how far the background (its color and images) is painted. It can even cut the background to the shape of the text.
background-origin
background-origin: border-box;
background-origin sets the area (outside the border, inside the border, or the content) that background images are placed in.
Border6
border
border: 8px solid #88d1c7;
border is a shorthand for an element’s border. It sets border-width, border-style and border-color in any order, and any of them can be omitted.
border-radius
border-radius: 48px 8px;
border-radius rounds the corners of an element. It is a shorthand for all four corners, and a / lets you give corners different horizontal and vertical radii for an elliptical shape.
border-image
border-image: url(/border-frame.svg) 30 round;
border-image is a shorthand that cuts an image or gradient into nine pieces and draws them in place of the border lines. The corners go in the four corners, and the edges are stretched or repeated to make a frame.
box-decoration-break
box-decoration-break: clone;
box-decoration-break sets how the background, border, padding, and rounded corners of an element split by a line or column break are drawn at the break.
outline
outline: 4px solid #4a86cb;
outline is a shorthand that draws a line outside an element. Like border, it takes a width, style and color in any order, but it never affects layout.
outline-offset
outline-offset: 12px;
outline-offset sets how far from the outer edge of the border an outline is drawn. Negative values pull it inside the element.
Effects14
Shadows, filters & blending5
Box shadows, blur and color filters, and blending with what lies underneath
box-shadow
box-shadow: 0 1px 2px #0f172a1f, 0 16px 40px -8px #0f172a40;
box-shadow casts shadows outside (or inside) an element’s frame. Separate several shadows with commas to layer them.
filter
filter: hue-rotate(90deg) drop-shadow(0 8px 12px #0f172a40);
filter applies image effects such as blur, brightness, and hue rotation to everything an element draws, children included. List several functions separated by spaces.
backdrop-filter
backdrop-filter: blur(8px);
backdrop-filter blurs or recolors whatever shows through behind an element. It is the go-to property for frosted-glass panels.
mix-blend-mode
mix-blend-mode: multiply;
mix-blend-mode sets how an element’s colors mix with whatever is drawn behind it, just like the blend modes in image editors.
isolation
isolation: isolate;
isolation sets whether an element is cut off as its own blending group. With isolate, mix-blend-mode on its children no longer blends with what lies behind the element.
Opacity & visibility2
How transparent an element is, and whether it is shown
Clipping & masking7
Cutting an element to the shape of a figure or an image
mask-image
mask-image: linear-gradient(to bottom, #000000 40%, #00000000);
mask-image uses the transparency of an image or gradient to let parts of an element show through, for soft fades or pattern-shaped cutouts.
mask-size
mask-size: 50%;
mask-size sets how large a mask image is drawn. It takes the same values as background-size: give a width and height directly, or use cover and contain to fit the element.
mask-repeat
mask-repeat: space;
mask-repeat sets whether a mask image is tiled and how the tiles are laid out. The initial value, repeat, tiles it like wallpaper, so use no-repeat to place it once.
mask-position
mask-position: 25% 75%;
mask-position sets where a mask image sits. It takes the same values as background-position: the horizontal then the vertical position, with keywords, lengths or percentages.
mask-mode
mask-mode: luminance;
mask-mode sets whether a mask image hides the element by its transparency or by its brightness. With luminance, white areas show the element and black areas hide it.
mask-composite
mask-composite: subtract;
mask-composite sets how several stacked mask layers combine. Add, subtract, keep only the overlap or remove only the overlap, and make new shapes out of two.
clip-path
clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
clip-path cuts an element down to a shape. Everything outside the circle, ellipse, rectangle or polygon becomes invisible.
Transform10
transform
transform: translateX(40px) rotate(15deg);
transform moves, rotates, scales and skews an element. List several functions separated by spaces and they combine in order.
translate
translate: 40px 20px;
translate moves an element horizontally and vertically. It does the same as the translate() function of transform, as a property separate from transform.
rotate
rotate: 30deg;
rotate turns an element. It does the same as the rotate() function of transform, as a property separate from transform.
scale
scale: 1.5;
scale makes an element larger or smaller. It does the same as the scale() function of transform, as a property separate from transform.
zoom
zoom: 1.5;
zoom enlarges or shrinks an element along with its contents. Unlike scale, it pushes surrounding elements away as it grows.
transform-origin
transform-origin: left top;
transform-origin sets the point that rotation and scaling happen around. The initial value is the center of the element.
perspective
perspective: 300px;
perspective sets how far away you are looking from when child elements are rotated or moved in 3D, giving them depth. The smaller the value, the closer you are: near parts look bigger and far parts smaller.
perspective-origin
perspective-origin: right top;
perspective-origin sets the point of the element that you look at straight on (the vanishing point) when perspective adds depth.
transform-style
transform-style: preserve-3d;
transform-style sets whether children moved in 3D share the element’s 3D space or are drawn flat onto its surface.
backface-visibility
backface-visibility: hidden;
backface-visibility sets whether an element rotated in 3D so that its back faces you is shown or hidden.
Images3
object-fit
object-fit: contain;
object-fit sets how the content of an img or video fits inside the element’s frame. Use it to show images whose aspect ratio differs from the frame without distorting them.
object-position
object-position: 25% 75%;
object-position sets where the content of an img or video sits inside the element’s frame. It is written just like background-position.
image-rendering
image-rendering: pixelated;
image-rendering tells the browser whether to favor smoothness or crispness when an image is drawn larger or smaller than its size. Use it to scale up pixel art or QR codes without blurring them.
Fonts11
Typeface, size & line height4
Which font to use, the text size, and the line height
font-size
font-size: 40px;
font-size sets the size of text. Besides fixed px values, you can use em, rem and % relative to the parent or root text size, or keywords such as small and large.
font-size-adjust
font-size-adjust: 0.5;
font-size-adjust adjusts the font size so that text looks about the same size even when the font changes, by matching a measure such as the height of lowercase letters. It keeps text from suddenly looking smaller when a fallback font is shown.
font-family
font-family: serif;
font-family chooses the font for text. List font names separated by commas, and the first one installed on the viewer's device is used.
line-height
line-height: 2;
line-height sets the height of each line. A unitless number means a multiple of the font size.
Weight & style3
How bold or slanted the text is, and whether the browser fakes a bold or italic the font lacks
font-weight
font-weight: 300;
font-weight sets how thick the text is, as a number from 1 to 1000 or a keyword such as normal or bold.
font-style
font-style: italic;
font-style sets whether text is slanted. You can choose the italic face (italic) or the regular glyphs slanted (oblique).
font-synthesis
font-synthesis: none;
font-synthesis decides whether the browser may fake bold, italic, or small-caps glyphs by transforming the regular ones when the font lacks them.
Glyph variants4
Choose among the glyphs a font carries, such as number styles, small caps, and kerning
8,888.00
3/4 · 1st
font-variant-numeric
font-variant-numeric: tabular-nums diagonal-fractions;
font-variant-numeric switches the glyphs used for digits, choosing among those the font has: equal-width digits that line up in columns, a single fraction glyph for "3/4", and so on.
font-variant-caps
font-variant-caps: small-caps;
font-variant-caps changes how capitals are shown, for example turning lowercase letters into small capitals: capital letterforms shrunk to the height of lowercase letters.
font-kerning
font-kerning: normal;
font-kerning decides whether to tighten pairs such as "AV" and "To" using the kerning data in the font.
11:11 · 1/2
88:88 · 3/4
font-feature-settings
font-feature-settings: "tnum", "frac";
font-feature-settings turns OpenType features of a font, such as kerning or digit widths, on and off directly with four-letter tags. Use it for features the font-variant properties cannot express, or for glyphs specific to a font.
Text styling18
Text color1
The color of the text itself
Lines, shadows & strokes7
Underlines and other lines, shadows, and outlined text
text-shadow
text-shadow: 2px 4px 6px #0f172a40;
text-shadow casts shadows that follow the shape of the text. Separate several shadows with commas to layer them.
text-decoration
text-decoration: underline wavy #e66465 3px;
text-decoration is a shorthand for drawing underlines, overlines and strikethroughs. It takes the line kind, style, color and thickness in any order.
-webkit-text-stroke
-webkit-text-stroke: 3px #4a86cb;
-webkit-text-stroke draws a line along the outline of the text. It is a shorthand taking a width and a color in any order.
paint-order
paint-order: stroke;
paint-order sets the order in which the fill, the stroke, and the markers of text or an SVG shape are painted. Moving a -webkit-text-stroke outline under the fill outlines text on the outside without making the letters thinner.
text-underline-offset
text-underline-offset: 12px;
text-underline-offset sets how far below the text an underline is drawn, for example to drop link underlines a little.
text-underline-position
text-underline-position: under;
text-underline-position sets where an underline is drawn: at the bottom of the text so it clears descenders such as "g" and "p", or on the left or right side in vertical text.
text-decoration-skip-ink
text-decoration-skip-ink: none;
text-decoration-skip-ink sets whether underlines and overlines break where they would cross the glyphs. With the initial value, auto, an underline breaks around descenders such as those of y and p.
Emphasis marks2
Dots set beside characters, common in vertical Japanese
text-emphasis
text-emphasis: filled sesame #e66465;
text-emphasis is a shorthand that puts an emphasis mark on every character, as in Japanese and Chinese typography. It sets the mark shape and color together.
text-emphasis-position
text-emphasis-position: under;
text-emphasis-position sets which side of the text the emphasis marks (text-emphasis) go on: above or below in horizontal text, right or left in vertical text.
Ruby2
Where small reading hints go beside the base text
ruby-position
ruby-position: under;
ruby-position sets whether ruby annotations (reading aids such as furigana) go above or below their base text. It applies to ruby written with the HTML <ruby> and <rt> elements.
ruby-align
ruby-align: start;
ruby-align sets how the shorter of a ruby annotation and its base text is laid out when their lengths differ: pushed to the start, centered, or spread out.
Quotation marks1
The quotation marks shown before and after <q> elements
Spacing & case5
Spacing between letters and words, CJK/Latin gaps, and case conversion
text-transform
text-transform: uppercase;
text-transform changes the case of letters, or half-width to full-width, purely in how the text is displayed.
letter-spacing
letter-spacing: 0.2em;
letter-spacing adds space between characters. Negative values pull them closer together.
text-spacing-trim
text-spacing-trim: trim-start;
text-spacing-trim decides whether to trim the blank space in fullwidth punctuation such as Japanese brackets and commas. It can remove the half-character gaps where punctuation marks meet and at the start of a line.
text-autospace
text-autospace: normal;
text-autospace decides whether to add a little space where Chinese or Japanese characters directly touch Latin letters or digits, so "CSSを学ぶ" reads like "CSS を学ぶ" without typing the space.
word-spacing
word-spacing: 0.5em;
word-spacing sets extra width added to the spaces between words. Negative values pull words closer together.
Paragraphs & wrapping18
Alignment & indent5
Horizontal alignment of lines and the first-line indent
text-align
text-align: center;
text-align sets which side the text in each line leans toward. It can also center or justify the text.
text-align-last
text-align-last: center;
text-align-last sets how the last line of a paragraph is aligned. In a justified paragraph you can center the last line, or stretch it to the full width as well.
text-justify
text-justify: inter-character;
text-justify decides where extra space goes when justified text (text-align: justify) is stretched to the full width: only between words, or between characters.
text-indent
text-indent: 2em;
text-indent sets the indentation of the first line of a paragraph. Negative values push the first line out to the left.
vertical-align
vertical-align: middle;
vertical-align sets where an image or other inline element sits vertically within its line. On a table cell, it sets where the cell’s contents sit vertically.
Line breaking & wrapping9
Where lines break and how spaces and long words are handled
word-break
word-break: break-all;
word-break changes the rules for where lines may wrap. It can break English words mid-word or wrap Japanese at phrase boundaries.
overflow-wrap
overflow-wrap: anywhere;
overflow-wrap sets whether long words and URLs that would overflow their box may wrap in the middle.
line-break
line-break: strict;
line-break sets how strict the rules are that keep punctuation, small kana such as "っ", and similar characters from starting a line. It mainly matters for Japanese and Chinese text.
hyphens
hyphens: auto;
hyphens decides whether a word that does not fit on a line may be split, with a hyphen (-) added before the break. In languages that separate words with spaces, such as English, it evens out the ragged right edge.
hyphenate-character
hyphenate-character: "=";
hyphenate-character sets the character shown where a word is split at the end of a line, normally a hyphen.
white-space
white-space: pre-wrap;
white-space decides how the spaces and line breaks written in the HTML are handled, and whether lines wrap.
white-space-collapse
white-space-collapse: preserve;
white-space-collapse sets whether runs of spaces and line breaks written in the HTML collapse into one, or stay as written. It is the part of white-space that does not cover wrapping.
tab-size
tab-size: 4;
tab-size sets the width of one tab character. A number means that many spaces; a length sets the width directly. It is often used to set the indent width when showing code.
text-wrap
text-wrap: balance;
text-wrap decides whether lines wrap and how the break points are chosen. It can even out the line lengths of a heading or avoid a single word on the last line.
Truncation2
Cut off text that does not fit with an ellipsis
text-overflow
text-overflow: ellipsis;
text-overflow decides how text that overflows its box ends. With ellipsis, the cut is marked with "…".
-webkit-line-clamp
-webkit-line-clamp: 2;
-webkit-line-clamp cuts text off after a set number of lines and adds "…" at the end of the last one. It is handy for keeping card descriptions to two or three lines.
Text box trimming2
Trim the extra space above and below lines
text-box-trim
text-box-trim: trim-both;
text-box-trim removes the space outside the text above the first line and below the last line of a block. It fixes text that looks too low even with equal top and bottom padding.
text-box-edge
text-box-edge: cap alphabetic;
text-box-edge sets how far text-box-trim cuts into the text, such as to the top of capital letters or to the baseline, so the space above and below the text can match.
Lists3
list-style-type
list-style-type: decimal;
list-style-type sets the kind of marker in front of each list item. Besides bullets and numbers, it offers counting systems such as Japanese iroha order and kanji numerals, or any character you like.
list-style-position
list-style-position: inside;
list-style-position sets whether the list marker sits outside the item or inside it.
list-style-image
list-style-image: url(/marker-star.svg);
list-style-image uses an image instead of a bullet or number as the marker at the start of each list item. If the image cannot be loaded, the list-style-type marker is shown instead.
Tables5
| 個数 | |
|---|---|
| りんご | 3 |
| みかん | 5 |
border-collapse
border-collapse: collapse;
border-collapse decides whether table cells draw their own separate borders or share a single border with their neighbors.
| 個数 | |
|---|---|
| りんご | 3 |
| みかん | 5 |
border-spacing
border-spacing: 0.5em 0.25em;
border-spacing sets how much space to leave between the cells of a table.
| 個数 | |
|---|---|
| りんご | 3 |
| みかん | 5 |
caption-side
caption-side: bottom;
caption-side sets whether a table’s caption (the caption element) goes above or below the table.
| 個数 | |
|---|---|
| りんご | 3 |
| みかん | 5 |
empty-cells
empty-cells: hide;
empty-cells sets whether the borders and background of empty table cells are drawn.
| 個数 | |
|---|---|
| りんご(ふじ) | 3 |
| みかん | 5 |
table-layout
table-layout: fixed;
table-layout sets whether table column widths come from the contents of the cells, or only from the table width and the first row.
Writing modes5
writing-mode
writing-mode: vertical-rl;
writing-mode sets whether text runs horizontally or vertically, and which way lines advance. Japanese vertical text uses vertical-rl.
text-orientation
text-orientation: upright;
text-orientation sets whether characters stand upright or lie sideways in vertical text. Use it to stack Latin letters upright.
text-combine-upright
text-combine-upright: all;
text-combine-upright sets characters such as digits side by side within the space of one character in vertical text. Known in Japanese typesetting as tate-chu-yoko, it keeps numbers like "10" or "30" upright and easy to read.
こんにちは、世界!
مرحبا بالعالم!
direction
direction: rtl;
direction sets whether characters in a line run left to right (ltr) or right to left (rtl). Use it for languages written right to left, such as Arabic and Hebrew.
こんにちは、世界!
مرحبا بالعالم!
unicode-bidi
unicode-bidi: plaintext;
unicode-bidi sets, for text that mixes right-to-left and left-to-right scripts, whether an element's content is ordered apart from its surroundings or in a forced order that ignores each character's direction. Use it together with direction.
Interaction14
Pointer and selection4
The pointer shape and whether it hits an element, text selection, and the resize handle
cursor
cursor: pointer;
cursor sets the shape of the cursor shown when a mouse or other pointer is over the element.
pointer-events
pointer-events: none;
pointer-events sets whether an element receives mouse and touch input. With none, input passes through the element to whatever is behind it.
user-select
user-select: none;
user-select sets whether the text in an element can be selected by dragging or double-clicking, and how it gets selected.
resize
resize: both;
resize adds a handle to the corner of an element so people can drag to change its size. You can limit it to one direction.
Form controls and color scheme5
Colors and looks of checkboxes, text fields, and other controls, and the color scheme of browser-drawn parts
accent-color
accent-color: #e0951a;
accent-color sets the highlight color (the accent color) of form controls such as checkboxes and radio buttons.
caret-color
caret-color: #e0951a;
caret-color sets the color of the caret, the blinking mark where typed text goes in a text field.
appearance
appearance: none;
appearance sets whether form controls are drawn with the look the browser provides. With none, things like the arrow on a select disappear, so you can style it from scratch with CSS.
color-scheme
color-scheme: dark;
color-scheme tells the browser whether an element can be drawn in a light or a dark color scheme. Form controls such as checkboxes and text fields, scrollbars, and system colors like Canvas then follow that scheme.
field-sizing
field-sizing: content;
field-sizing sets whether text inputs and text areas grow and shrink to fit the text inside them. With content, they widen as you type.
Scrolling5
How scrolling moves, and making it come to rest at set positions
scroll-behavior
scroll-behavior: smooth;
scroll-behavior sets whether scrolling triggered by in-page links or JavaScript jumps straight to the target or moves there smoothly. With smooth, it scrolls smoothly to the target position.
scroll-snap-type
scroll-snap-type: y mandatory;
scroll-snap-type sets whether a scrolling box snaps to the position of an element inside it when scrolling stops. You give the direction and the strictness.
scroll-snap-align
scroll-snap-align: start;
scroll-snap-align sets which part of an element lines up with which part of a snapping scroll box when scrolling stops. With start, the start of the element lines up with the start of the box.
scroll-padding
scroll-padding: 24px;
scroll-padding sets how far inside the edges of a scrolling box a snapped element or a link target comes to rest. Use it to keep targets from hiding under a fixed header.
scroll-margin
scroll-margin: 24px;
scroll-margin sets how much room to leave around an element when scrolling snaps to it or a link jumps to it. It shifts where each element comes to rest.