Release notes, version 4.2
Exports now keep your layer names, and the colour picker remembers your last ten swatches.
- Faster PDF export
- New keyboard shortcut for duplicate
Thanks to everyone who reported the font bug.
A guided route through sixteen new CSS features. Each stop has five short steps: get the idea, play with a live lab, explore every option, answer one question, then build something real. Your progress is saved in this browser.
Go in order or jump to any stop. Finished stops turn green and your next stop is blue.
Stacks of paragraphs or cards leave extra margin above the first child and below the last. margin-trim goes on the container and removes that edge margin, so only the space between children is left.
One
Two
Three
noneblockblock-start / block-endinlineinline-start / inline-endblock inlineWhen the container is flex or grid, gap is often the better tool. margin-trim is for ordinary block flow, such as article bodies, cards, or CMS content where you don’t control the markup.
Exports now keep your layer names, and the colour picker remembers your last ten swatches.
Thanks to everyone who reported the font bug.
A quick way to replace list bullets or numbers with your own characters, right inside list-style. You choose a system, which decides what happens when the list runs out of symbols, and then give the symbols.
@counter-style, which works in all browsers.
cyclicfixedsymbolicalphabeticnumeric"0" "1" counts in binary: 1, 10, 11, 100…@counter-styleprefix, suffix, range, pad and fallback. It works with counter() anywhere, not just in lists.progress(value, start, end) tells you how far a value is between two points, as a number from 0 to 1. Values outside the range are clamped. On its own that sounds dull. Once you multiply it into widths, hues, radii or opacity, it can do a lot of the work of an if statement.
progress(v, a, b)(v − a) / (b − a), clamped between 0 and 1. All three arguments must be the same type: three numbers, or three lengths, and so on.progress(var(--total), 0, 75). Usually fed from a custom property that JavaScript or an inline style sets.progress(100cqi, 260px, 640px) gives a container size as a ratio, which is the basis for fluid components.round()round(down, var(--p), 1) is 0 until the ratio reaches 1, then becomes 1. That works as an on/off switch for opacity, display widths or scale.calc()calc(12px + var(--p) * 28px) moves smoothly from 12px to 40px.Add more for free shipping You unlocked free shipping
Cart total:
light-dark() used to accept colours only. It now takes images as well: url() files, and gradients, which also count as images. Set color-scheme: light dark, then give the light value first and the dark value second.
Same element, same CSS.
color-schemelight dark follows the user’s system. light or dark forces one theme for that element and its children.light-dark(<color>, <color>)light-dark(<image>, <image>)url(), linear-gradient(), radial-gradient(), conic-gradient() and so on, in background-image, list-style-image, border-image and mask-image.Forty pitches, no light pollution.
A relative colour function that changes only the transparency of a colour and leaves the rest alone. Write alpha(from var(--brand) / 0.2), and one brand variable can supply the text colour, a tinted background, the border and the hover state.
rgb(from var(--c) r g b / 0.2) for the same result in older browsers.
alpha(from C / A)alpha keywordalpha is the original colour’s alpha. calc(alpha * 0.5) halves it, even if it was already translucent.nonealpha(from C / none) marks the alpha as a missing component, which matters when you interpolate.rgb(from …)rgb(from C r g b / A). alpha() works the same way whatever colour space C is in.Payment failed. Your card was declined. Try another card.
Backup complete. 2,314 files copied at 09:12.
New version ready. Restart to install it.
random(min, max) picks a value in that range when styles are computed. Each element gets its own value, and you get a new set on every page load. Add a step and the values snap to fixed increments. Add a key and you control which elements and properties share the same random value.
random(min, max)random(min, max, step)min + n × step. Use it for a fixed set of hues, 15° rotations, or snapping to a grid.autorandom() within a property gets its own independent value.element-scopedproperty-scoped--namerandom() with the same name and the same range gets the same value, even across elements.fixed 0.42random-item(key, a, b, c)You’ve probably used text-overflow: ellipsis to add “…” to clipped text. It now also accepts a string, so a cut-off line can end with whatever you want. With two values, you can mark both ends of a line you scroll through.
Drag the box’s corner to resize it.
clipellipsis"string"" [+]" or "…→". If the box is too narrow, the string itself gets clipped."left" "right"overflow other than visible and with text that doesn’t wrap (white-space: nowrap).With both, the browser snaps each axis separately. On a layout that isn’t a perfect grid, you can end up lined up with item 4 horizontally and item 5 vertically, so you’re centred on neither. pair chooses one target for x and y together.
both first and pair second.
x / y / block / inlinebothpairmandatoryproximityscroll-snap-alignstart, center or end, and one value per axis is allowed.sibling-index() gives an element’s position among its siblings, starting at 1. sibling-count() gives how many siblings there are. Both are integers you can use in calc(), which replaces stacks of :nth-child rules and style="--i: 3" attributes.
sibling-index()calc(sibling-index() - 1).sibling-count()sibling-count() - sibling-index() counts down to 0 at the last child. Use it for reverse staggers and z-index stacks.sibling-index() - (sibling-count() + 1) / 2 is 0 for the middle child, negative to the left and positive to the right. That’s what makes a fan of cards.Anything with a gap (grid, flex or multi-column) can now draw lines inside that gap, much like borders. You can also change colour and style from one gap to the next, decide what happens where lines cross, shorten the ends, and hide lines next to empty cells.
rulerule: 1px solid gray.column-rule / row-rulecolumn-rule used to work only in multi-column layout and now works in grid and flex too. Each has -width, -style and -color longhands.repeat()red, blue alternates, and repeat(2, red), green gives red, red, green.rule-breaknormal lets lines stop at spanning items. none draws straight through everything. intersection breaks a line wherever gaps cross. There are per-axis column-rule-break and row-rule-break too.rule-insetrule-inset-cap affects only the free ends of a line. rule-inset-junction affects only the ends where lines meet.overlap-joinrule-visibility-itemsall draws every gap. around draws only next to real items, so empty cells get no lines. between draws only where items sit on both sides.Give it a background colour and the browser returns whichever of black or white reads better on it. If you chose the colours yourself, just pick good ones. Where this really helps is when users pick colours: tags, labels, calendar events, team colours.
contrast-color(C)white or black, whichever contrasts more with C. That’s the whole interface for now.path() takes SVG path syntax with fixed pixel values, so it can’t stretch. shape() describes the same kind of drawing with CSS words and CSS units: percentages, calc() and variables. The shape can grow with its box while details such as an arrow tip stay a fixed size. Use it with clip-path or offset-path.
Drag the corner. The 40px tip keeps its size.
from x ynonzero or evenodd first to set the fill rule.move to / byto is absolute and by is relative to the current point.line to / byhline / vlinecurve to P with C1 [/ C2]smooth to P [with C]arc to P of R [cw|ccw] [large|small] [rotate θ]closeshape() values with the same list of commands interpolate smoothly, so you can morph one into the other.Six Saturdays of letterpress, binding and risograph.
Running late!
No worries. We saved you a seat by the window, and the soup of the day is pumpkin.
border-radius sets how big a corner is. corner-shape sets what form it takes. The background, border, outline and shadow all follow the new shape.
roundsuperellipse(1).squirclesuperellipse(2).bevelsuperellipse(0).scoopsuperellipse(-1).notchsuperellipse(-infinity).squaresuperellipse(infinity).superellipse(k)border-radius, plus longhands such as corner-top-left-shape.Attach one element to another, so a tooltip or menu sits beside its button. When it would run out of space, it flips to the other side. Together with the popover attribute, this covers what tooltip libraries like Popper or Floating UI used to do, with no JavaScript.
anchor-name--menu-btn. A dashed ident is required.position-anchorposition-areatop, bottom right, left center, and with span-* you can stretch across two cells: bottom span-right.anchor()top: anchor(bottom), left: anchor(center).anchor-size()min-width: anchor-size(width) keeps a menu at least as wide as its button.position-try-fallbacksflip-block (up and down), flip-inline (left and right), flip-start, other position-area values, or your own @position-try rules.position-try-ordermost-height.position-visibilityanchors-visible hides the element when its anchor scrolls out of view. no-overflow hides it when it can’t fit.popover + popovertargetInbox
Drafts
Invoices
Sent
Archive
Spam
Receipts
Travel
Family
Newsletters
Old projects
Misc
3 unpaidSeven pseudo-classes describe what an <audio> or <video> element is doing right now. Combined with :has(), the rest of the page can respond to a video without any event listeners.
:playing:paused:playing or :paused.:seeking:buffering:playing.:stalled:mutedmuted attribute or property).:volume-lockedUnderlines have always run the full width of the text. text-decoration-inset moves where they start and end: a positive value pulls the ends in, a negative value pushes them out. It can be animated, so the classic “underline grows from the middle” effect no longer needs a pseudo-element.
Underline me
The red line is the text decoration.
0<length><start> <end>1em -1em shifts the whole line to the right.autotext-underline-offsettext-decoration-skip-inknone stops the line from breaking around descenders. You need it when the line sits behind the letters.The meeting moved to Thursday at 3pm, in the small room.
One line to remember from each stop. Select a feature to go back to its lesson.
| Feature | The line to remember | In this browser | You |
|---|
Built from a walkthrough video of 16 new CSS features, checked against MDN (random(), random-item(), shape(), alpha(), text-decoration-inset, media pseudo-classes), Chrome’s gap decorations announcement, and the CSS Gaps, Shapes and Scroll Snap drafts. Specs still change, especially the rule-* names and defaults.