Critical CSS is the minimal subset of style rules required to render the content visible in the first viewport of a page, delivered inline in the HTML document so the browser can paint without waiting for external stylesheets. In web performance, it is a technique for removing render-blocking CSS from the critical rendering path and improving metrics such as FCP and LCP.
The remaining, non-critical CSS is loaded asynchronously and applied after the first paint. The idea is simple, but a correct implementation requires careful extraction, size budgeting and a strategy for keeping the inlined rules synchronized with the full stylesheet.
Why stylesheets block the first paint
Browsers treat external stylesheets as render-blocking resources because painting unstyled content and then restyling it would cause a flash of unstyled content and costly relayout. Until every stylesheet linked in the head has been downloaded and parsed into the CSS Object Model (CSSOM), the browser cannot build the render tree and cannot paint.
On a fast connection the delay is small, but on mobile networks each stylesheet request can cost one or more round trips plus download time. A page that links a 150 KB framework stylesheet may wait hundreds of milliseconds after the HTML arrives before showing anything. Critical CSS shortens this wait by putting the styles needed for the above-the-fold content directly into a style element in the head, so the first paint depends only on the HTML response.
The following table shows how each stage of the rendering path is affected when critical styles are inlined.
| Rendering stage | Full external stylesheet | Critical CSS inlined |
|---|---|---|
| HTML download | Required | Required, slightly larger |
| Stylesheet request | Blocks rendering | Deferred until after paint |
| CSSOM construction | Waits for full file | Starts from inline rules |
| First paint | After stylesheet arrives | After HTML is parsed |
| Full styling | At first paint | When deferred file loads |
How critical CSS is extracted and delivered
Extraction tools render the page in a headless browser at one or more viewport sizes, record which elements appear inside the viewport, and keep only the selectors that match those elements. Popular build tools such as Critical, Penthouse and Critters automate this step, and some frameworks perform it during server-side rendering or static generation.
Delivery follows a standard pattern. The extracted rules go into a style element in the document head, and the full stylesheet is loaded without blocking, typically with a preload hint or with a link whose media attribute is switched to all after loading. A noscript fallback keeps the page styled when JavaScript is disabled.
- Render representative templates at mobile and desktop widths.
- Collect the selectors used by elements in the first viewport.
- Include required font-face and custom property declarations.
- Minify the result and inline it in the head.
- Load the complete stylesheet asynchronously and cache it.
The next table compares common extraction approaches and where each fits best.
| Approach | How it works | Best suited to |
|---|---|---|
| Build-time extraction | Headless rendering of templates during the build | Static sites and stable templates |
| Runtime extraction | Server computes rules per request or caches per route | Highly dynamic pages |
| Component-scoped CSS | Styles emitted only for rendered components | Component frameworks with SSR |
| Manual curation | Developers maintain a hand-written critical file | Small sites with few layouts |
Size budget and key parameters
The value of critical CSS depends on keeping the inlined block small. The guideline rests on TCP slow start: an initial congestion window of about 10 packets, roughly 14 KB compressed, can arrive in the first round trip. If the HTML together with the inline styles fits within that window, the browser can begin rendering after a single round trip from the server response.
With HTTP/2 and HTTP/3 the exact threshold matters less than in the past, but the principle remains: every inlined byte delays the HTML and is downloaded again on each page view because inline styles cannot be cached separately. Typical well-tuned critical blocks range from 5 KB to 20 KB uncompressed.
| Parameter | Typical value or choice | What it affects |
|---|---|---|
| Inline size | 5-20 KB uncompressed | HTML transfer time and parse cost |
| Viewport sizes | One mobile and one desktop width | Coverage of above-the-fold layouts |
| Template coverage | One block per page type | Accuracy across different layouts |
| Fonts in scope | Primary text font only | Text rendering and layout shift |
| Regeneration trigger | Every build or deploy | Drift between inline and full CSS |
How critical CSS relates to neighboring techniques
Critical CSS is one of several techniques that address the critical rendering path, and it is often combined with them rather than used alone. It targets render-blocking styles specifically, while preload, minification and code splitting address other parts of the loading sequence.
| Technique | Main goal | Relationship to critical CSS |
|---|---|---|
| Preload | Fetch a resource earlier | Often used to load the deferred stylesheet |
| Minification | Reduce file size | Applied to both inline and full CSS |
| Code splitting | Load only needed code | Similar principle applied to JavaScript |
| Lazy loading | Defer offscreen media | Complements deferred non-critical styles |
| Unused CSS removal | Delete rules never used | Shrinks the full file, not the first paint path |
The effect is measured mainly through First Contentful Paint and Largest Contentful Paint. A correct implementation should not worsen Cumulative Layout Shift; if it does, the critical block is missing rules that define dimensions or positions of visible elements.
Limitations and common mistakes
Critical CSS adds build complexity and a maintenance burden, and its benefits shrink when stylesheets are already small, cached or served from the same connection as the HTML. Sites with mostly returning visitors gain less, because a cached stylesheet no longer blocks rendering in a meaningful way.
| Symptom | Likely cause | Fix |
|---|---|---|
| Layout jumps after load | Missing dimension or grid rules | Widen extraction viewports, add rules |
| Flash of wrong styles | Inline rules outdated after deploy | Regenerate on every build |
| Slower HTML delivery | Inline block too large | Trim selectors, split per template |
| Unstyled page without JavaScript | No noscript fallback | Add a blocking link inside noscript |
| Duplicate style bytes | Rules repeated in both files | Accept or exclude inlined rules from full file |
A frequent misconception is that inlining all CSS is equivalent. Inlining a large stylesheet removes the extra request but inflates every HTML response and defeats caching, which usually harms repeat visits. Another mistake is extracting only at a desktop width, which leaves mobile layouts without the rules they need.
A non-technical view
Before a browser shows a page, it normally waits for the full design file that describes colors, fonts and layout. Critical CSS hands the browser a small excerpt of that file, covering only what appears on the screen first, so it can start drawing right away.
Think of a restaurant that brings bread and water the moment guests sit down, while the kitchen prepares the full meal. Visitors see something useful almost immediately, and the rest of the styling arrives quietly a moment later.
A concrete example
A news publisher serves article pages that link a 160 KB framework stylesheet. Field data shows a median First Contentful Paint of about 2.6 seconds on mobile, largely because the stylesheet blocks rendering on slower connections.
The front-end team adds a build step that renders the article template at 375 and 1280 pixels wide, extracts about 11 KB of critical rules, inlines them in the head and loads the full stylesheet asynchronously with a noscript fallback. The block is regenerated on every deploy.
After release, median mobile FCP drops to roughly 1.5 seconds and LCP improves by several hundred milliseconds, while layout shift stays unchanged. The outcome is a visibly faster first paint at the cost of a slightly larger HTML response.