{"canonical_url":"https://engineer.company/glossary/css/","content_markdown":"# CSS\n\n## What it is\n\nCSS, short for Cascading Style Sheets and still often called CSS3, is the rule\nlanguage a browser applies to a document to decide how each element is drawn:\nits colours, size, spacing, position, typeface and movement, whether the\ndocument lands on a phone, a wide monitor or a sheet of paper.\n\nA stylesheet is a list of rules. Each rule pairs a selector, which picks out\nelements, with declarations, each one a property and a value:\n\n```css\n.note {\n    color: #3a3a3a;\n    margin-block: 1.5rem;\n}\n```\n\nThe first word of the name is the part that shapes daily work. Several rules\nroutinely claim the same property of the same element, and the cascade decides\nwhich one wins. Its main steps, in order, are origin and importance (the\nbrowser's defaults, the reader's own settings, the site's stylesheet, and\nwhether a declaration is marked `!important`), then cascade layer, then\nspecificity, and finally order of appearance, where a later rule beats an\nearlier one of equal weight. Specificity is counted per selector as three\nnumbers: IDs, then classes, attributes and pseudo-classes, then element names.\nThe universal selector `*` adds nothing to any of them. Inheritance works\nalongside the cascade: some values, such as colour and font, pass down to an\nelement's children, while others, such as margins and borders, stay where they\nwere set.\n\nCSS has no single version number. After CSS 2.1 the working group went\nmodular: Level 3 builds on 2.1 one module at a time, and from there each module\nis levelled on its own, so Selectors is drafted at Level 4 while modules with no\nolder equivalent start at Level 1. “CSS3” is the popular name for that modular\nera, and the yearly snapshot that defines current CSS states plainly that there\nis no CSS Level 4.\n\nThe rule with the most practical weight is how the language treats errors. A\nbrowser that meets a property it does not know, or a value that is invalid for\nits property, must ignore that one declaration and apply the rest of the rule.\nThe rule exists so that new properties and values can be added without breaking\nolder browsers, and it is what lets a site use a feature only some browsers\nsupport. Its price is silence. The page renders, slightly wrong, and the only\ntrace is a struck-through line in developer tools that someone has to go\nlooking for.\n\nMost of what is compared with CSS turns out to be a way of writing it. Sass and\nLess are preprocessors that compile to CSS. Utility frameworks such as Tailwind\ngenerate it from class names in the markup. CSS-in-JS libraries emit it from\nJavaScript components, and a `style` attribute puts declarations straight onto\none element. Each changes how CSS is authored; each ends as declarations the\ncascade sorts in exactly the same way.\n\n## Why it matters\n\nThe decision CSS forces on a team is where a rule is allowed to fail silently.\nThe language drops what it cannot apply and lets a stronger rule win without\ncomment, so every stylesheet of any age holds declarations that do nothing.\nWhat a team controls is whether anyone finds out, and when.\n\nAccessibility depends on it more than most people expect. Contrast, a visible\nfocus ring, honouring a request for reduced motion, a usable forced-colours\nmode, text that survives being enlarged: each one is a handful of declarations,\nand each can be switched off by a rule elsewhere that happens to be more\nspecific. The page looks fine to everyone who did not need the feature.\n\nMaintenance cost depends on it too. A stylesheet whose behaviour nobody can\npredict only grows, because deleting a rule might break a page nobody checked.\nThe usual end state is a file where most of the weight is overrides of earlier\noverrides, and every change is made by trying values until the screen looks\nright.\n\nVerification depends on it most directly. A browser that accepts what it can\nand ignores the rest cannot serve as the test. A linter reading the source\ncatches typos and invalid values before they ship. It cannot see what a\nminifier or any other build step does to the file afterwards, and it cannot see\nwhich of two valid rules wins on a given page. Checks against the served file,\nand visual comparison of rendered pages, cover what the linter cannot.\n\nOrganising the cascade early, with flat specificity, named layers and design\ntokens held in custom properties, costs a little discipline per change.\nReorganising a stylesheet that grew without that discipline usually costs a\nrewrite.\n\n## What it looks like in practice\n\nThe site's own [credits page](/credits/) describes one CSS bundle, concatenated\nand fingerprinted at build time, with the hand-drawn arrows and margin notes\ndrawn in CSS alone, and Stylelint holding the source to its rules in the gate.\nThe same page links the W3C CSS Validator and warns the reader what it will\nsay. As of August 2026 its profile stops short of `system-ui`, `@property`,\n`clamp()` in a `font-size` and scroll-driven animations, so against /terms/ it\nreported 176 complaints, 175 of them about features the browsers ship and the\nsite uses. The remaining one was real. A resting `rotate: 0deg` lost its unit to\nthe minifier, `rotate: 0` is not an angle, and the browser dropped the whole\ndeclaration, so an animation shipped without the rotation it was written with.\nThe values specification allows a bare zero for an angle only in a few legacy\nplaces. Stylelint never saw the problem, because it reads the source and the\nminifier rewrites it later; a check of the company's own now reads what was\nactually served.\n\nSpecificity was the whole story in a piece of accessibility work. The site\nhonoured the reduce-motion preference with one universal rule that turned every\ntransition off, and under an emulated preference\n[11 selectors were still animating](/portfolio/made-the-reduced-motion-setting-honest/).\nA universal selector scores zero, so any rule carrying a class beat it. The fix\nwas structural rather than a stronger selector: everything that moves now lives\nin one late stylesheet part, and a linter fails a transitioned transform\nanywhere else. Colour fades pass, since they are not motion, and motion must be\nwritten as a transition rather than a keyframe animation, because a transition\nis the one that cancels cleanly. The lesson recorded with it is short: a rule\nthat loses on specificity fails silently.\n\nColour is where stylesheets drift first, and the site's palette was\n[closed at 28 colours](/portfolio/closed-the-colour-system-at-28-colours/),\neach documented with the contrast ratio it measures on the surface where it\nappears, and 11 brand values declared once as tokens. Two colours closer than a\nperceptual distance of 0.02 count as one colour spelled twice, and the linter\nfound two near-duplicate spellings as soon as it ran. Transparency is written\nwith relative colour syntax rather than the mixing function, for a reason that\nsums up the whole page: the guard cannot see through a mix.\n\n## Where it goes wrong\n\n### A declaration vanishes and the page still renders\n\nOne wrong character makes a declaration invalid, and the browser skips it\nwithout stopping:\n\n```css\n.card {\n    padding: 16; /* a length needs a unit: ignored */\n    colour: #222; /* not a property name: ignored */\n    margin-block: 1rem; /* applied */\n}\n```\n\nThe card renders with a margin and without its padding or its colour, and the\nbrowser raises no alarm. Lint the source in the build and fail on its errors.\nWhere a minifier, preprocessor or bundler rewrites the CSS after the linter has\nrun, check the output as well, because that file is the one the browser reads.\n\n### A rule loses to a stronger one\n\nA component's rule meets a more specific selector from somewhere else, or an\nequal one loaded later, and loses. The usual reflex is a longer selector or an\n`!important`, which wins today and raises the price of the next change. Keep\nspecificity flat, with classes rather than IDs and little nesting, and use\ncascade layers to put whole groups such as reset, base, components and\nutilities in an explicit order that specificity cannot overturn. For\n`!important` declarations the layer order runs the other way, with the earliest\nlayer winning, which is worth knowing before reaching for it.\n\n### The stylesheet only ever grows\n\nNew work appends rules, because proving an old one unused takes longer than\nwriting another. Values get retyped as literals beside the tokens that define\nthem, and near-identical colours multiply until nobody can tell which is\nmeant. Hold shared values in custom properties, measure which rules a set of\npages actually uses, and delete as part of the work, with a size budget in the\nbuild to make growth visible.\n\n### The layout holds at one size only\n\nA design checked at one width with short English text breaks under longer\ntranslations, enlarged text and narrow phones. Fixed heights clip their\ncontent, and fixed widths force sideways scrolling. Accessibility guidelines\nask for text that can be enlarged to 200% and for content that reflows at a\nwidth of 320 CSS pixels. Size boxes from their content, use `min()`, `max()`\nand `clamp()` for fluid values, and test with long strings and zoom before\ncalling a layout done.\n\n## Further reading\n\n- [CSS Snapshot 2026](https://www.w3.org/TR/CSS/) — which modules make up CSS\n  today, and why the language has levels instead of versions.\n- [CSS Cascading and Inheritance Level 5](https://www.w3.org/TR/css-cascade-5/)\n  — the full sort order, cascade layers and inheritance, step by step.\n- [Selectors Level 4](https://www.w3.org/TR/selectors-4/) — every selector, and\n  how its specificity is calculated.\n- [Syntax and basic data types](https://www.w3.org/TR/CSS21/syndata.html) — the\n  CSS 2.1 rules for ignoring unknown properties and illegal values, with\n  examples.\n- [CSS Values and Units Module Level 4](https://www.w3.org/TR/css-values-4/) —\n  lengths, angles, `clamp()` and where a bare zero is still allowed.\n\n\u003chttps://engineer.company/glossary/css/\u003e\n","date_modified":"2026-10-20T21:59:50Z","description":"How CSS decides which rule styles an element, why its mistakes pass without a warning, and how a team makes sure a dropped declaration gets caught.","formats":{"gemtext":"https://engineer.company/glossary/css/index.gmi","gopher":"https://engineer.company/glossary/css/gophermap","html":"https://engineer.company/glossary/css/","json":"https://engineer.company/glossary/css/index.json","markdown":"https://engineer.company/glossary/css/index.md","pdf":"https://engineer.company/glossary/css/index.pdf"},"kind":"page","language":"en","title":"What is CSS?","url":"https://engineer.company/glossary/css/","version":1}