Which value wins
inheritunsetrevertTrap!important beats inline styles and every normal rule. Use it rarely.
box-sizing: border-box, width includes the padding and border.display sets how a box lays out its children, in normal flow, flex or grid. position: absolute and fixed take a box out of the flow.z-index only compares boxes in the same stacking context. opacity below 1 and transform each start a new one.transform and opacity skip layout and paint, so animate those.inheritunsetrevertTrap!important beats inline styles and every normal rule. Use it rarely.
*It adds no specificity.*, *::before, *::afterbox-sizing: border-box@layer base, utilities;A later layer beats any specificity.@scope (.card) to (.body)TrapUnlayered styles beat every layer, unless the layered rule is !important.
div pdiv > ph2 + ph2 ~ p[href^="https"][href$=".pdf"][href*="docs"]:nth-child(2n):nth-of-type(2)Trapp:nth-child(2) counts every sibling. After a heading, it matches the first paragraph.
:hover::before: for a state, :: for a part.counter-reset: itemcounter-increment: itemcontent: counter(item)::placeholderAdd opacity: 1, since Firefox dims it.::highlight(hit)TrapA placeholder is a hint, not a label. It disappears as the user types.
:is(h1, h2):where(.btn):where() adds none..card:has(img)h2:has(+ p)Trap:is(), :not() and :has() take their most specific argument, so :is(#a, p) weighs as much as an ID.
width include padding and borderbox-sizing: border-boxMargin is never included.margin-inline-start: 1remTrapUnder the default content-box, width: 200px plus 20px padding and a 5px border renders 250px wide.
display: flow-rootIt starts a block formatting context.display: nonevisibility: hidden.sr-only class that clips it to 1px.Tipopacity: 0 keeps the space and still takes clicks.
Trapdisplay: none and visibility: hidden both hide the element from screen readers too.
max-width: 1200pxWith width: 100%.min-width: 0overflow: autooverflow: clipscroll always shows scrollbars.TrapIf min-width and max-width conflict, min-width wins.
position: absoluteGive the parent position: relative.position: sticky; top: 0z-index that has no effectMove the box out of the parent's stacking context.anchor-name: --tipposition-anchor: --tipisolation: isolateTrapoverflow: hidden on a parent can stop sticky. A transform on an ancestor pins fixed to that ancestor.
justify-content: centeralign-items: centerflex: 1Short for 1 1 0%, which is grow, shrink, basis.Trapflex-direction: column swaps the axes, so justify-content then works vertically.
grid-template-columns: 200px 1fr 2frgrid-template-areas: "side main"grid-area: mainTrapPercentages ignore gap, so 20% 40% 40% plus a gap overflows. fr shares only what's left.
grid-template-rows: subgridcolumn-count: 3break-inside: avoidItems read down each column.display: gridplace-items: centertransform: translate(-50%, -50%)Set top and left to 50% first.TipFlex and grid items stretch to the tallest in their row, so columns match.
@media (min-width: 768px)Use max-width to build desktop first.@custom-media --sm (max-width: 30em);Needs PostCSS.TipMobile first keeps base styles simple, and phones skip the wider blocks.
container-type: inline-size@container (min-width: 300px)width=device-width, initial-scale=1In the viewport meta tag.font-size: 1.25remem uses the element's own font size.height: 100dvh100vh can run under it.TipTo clear a notch, add viewport-fit= and pad with env(safe-area-inset-top).
clamp(1rem, 4vw, 2rem)Minimum, preferred, maximum.calc(100% - 40px)Spaces around + and - are required.calc(cos(45deg) * 100px)TrapKeep a font's clamp() maximum in rem and at least twice the minimum, or text stops growing when users zoom.
max-width: 100%height: autosrcset="a-400.jpg 400w, a-800.jpg 800w"sizes says how wide it shows.object-fit: covercontain fits it all and may leave bands.transition: opacity 0.3s ease 0.1sThe first time is the duration, the second the delay.Traptransition: all also animates changes you didn't plan. Name each property.
@keyframes with from, to or percentages.animation: pulse 2s infinite alternateanimation-timeline: view()Not in every browser yet.scroll-snap-type: x mandatoryscroll-snap-align: startTrapWithout animation-fill-mode: forwards, the element snaps back when the animation ends.
transform: rotate(45deg) scale(1.2)The boxes around it don't move.transform-origin: top leftTrapOrder matters. A translateX after rotate moves along the rotated axis.
perspective: 1000pxSet it on the parent.backface-visibility: hiddenTurn the wrapper with rotateY(180deg).TrapTouch and keyboard users have no hover. Flip on :focus-within too.
--brand: #07fcolor: var(--brand, black)color-scheme: light darkIt won't change colors you set.light-dark(#333, #fff)TrapA plain custom property can't animate smoothly. Register it with @property first.
oklch(70% 0.1 180)linear-gradient(red, blue)background: paint(circle)Not in every browser.filter: blur(5px)drop-shadow() follows the pixels, not the box.clip-path: circle(50%)mask: linear-gradient(black, transparent):focus-visibleIt skips the ring on mouse clicks.@media (prefers-reduced-motion: reduce)<details><summary>:checked + .panelKeyboard and screen reader users can't open it.content: attr(data-tip)TrapCSS can't fix missing semantics. Never carry meaning by color alone.
appearance: nonefont: inherit:checked + label::beforeHide the input with opacity: 0.:user-invalidTrap:invalid matches an empty required field as soon as the page loads.
@media printSet display: none inside it.break-before: pagepage-break-before: alwaysTiporphans and widows set the fewest lines a paragraph leaves at a page break.
transformopacityThey skip layout and paint.will-change: transformRemove it after. Each layer costs memory.offsetHeight right after a style change.Trapwill-change creates a stacking context before anything moves, which can change z-index.
<link> tags, not chained @import.font-display: swapLoad the font with @font-face, as WOFF2.aspect-ratio: 16 / 9This keeps CLS low.contain: contentTrapInlined CSS repeats in every page and can't be cached on its own.
.card__title.card--featuredBlock, element, modifier.flex or p-2.card.module.cssCSS Modules. No runtime cost.--color-actionSemantic names point at raw values.&:hover { }TrapNative nesting can't build names like Sass's &__title.
@supports (display: grid)Add not for the fallback.Trap@supports proves the syntax parses, not that the feature works without bugs.
browserslist.TipA few properties still need a prefix, such as -webkit-line-clamp.
* { outline: 1px solid red; }Unlike a border, it doesn't change the layout.npx stylelint "**/*.css"TrapEmulators miss real taps and real speed. Test on real phones too.
Nothing matches. Try a shorter word, or clear the search.
With Pro, you can:
Already have Pro? Sign in