AI Artifacts & Generated Sites

Inline CSS

Definition

Two different things go by this name. A style element in the head holds ordinary CSS, with selectors, media queries and everything else the language offers, and applies to the whole document. A style attribute on an element holds declarations only, applies to that one element, and cannot express a hover state or a breakpoint. Both are what a chat assistant produces, because the output has to be one file that works when opened. Browsers apply the two at different strengths: attribute styles sit above any selector in the cascade, beaten only by a rule marked important. That is worth knowing before you spend an afternoon wondering why a class is being ignored.

Why It Matters

For a single page, inlining is genuinely faster. The stylesheet arrives with the HTML, so there is no second request and no unstyled flash while it loads — which on a high-latency connection saves 100 to 300 ms. Across several pages the maths reverses. An external stylesheet is downloaded once and cached; inlined CSS is re-sent with every page, so a 20 KB block across eight pages means 160 KB of repeated bytes instead of 20 KB fetched once. Editing gets worse too: a colour change has to be made in every file rather than one. The usual compromise is to inline the styles needed for the first screen and link the rest.

How It Works

The browser parses the HTML top to bottom; a style element blocks rendering only as long as it takes to read, since there is nothing to fetch. Rules are then resolved by the cascade — origin, then specificity, then document order — with style attributes counted above all selectors. Nothing here needs special handling from a host: a page with its CSS inlined is a single HTML file, so it is served, compressed and cached as one object, and a static host like 99helpers never has to know the difference. If you later split the CSS out, the link tag needs a correct relative path and the server must send the file with a text/css content type, or the browser ignores the rules entirely.

Real-World Example

A freelancer publishes a one-page CV at jo-cv.99helpers.site through 99helpers, with about 6 KB of CSS in a style element. The whole page is 19 KB and paints in a single round trip. When the same design grew into five pages, the CSS moved into 'style.css' next to the HTML — the same 6 KB now cached across all five instead of sent five times, and one file to edit when the accent colour changed.

Common Mistakes

  • Using style attributes for anything that needs a hover or a media query — the attribute cannot hold either
  • Repeating a large inline block across many pages, which throws away caching and makes edits error-prone
  • Fighting a style attribute with a class and reaching for important, when moving the declaration into the stylesheet solves it cleanly
  • Splitting the CSS out later and forgetting the relative path, so the page loads unstyled and looks broken

Related Terms

Put a file online in seconds

Drop in a document, an image, a page or a whole static website and share the link — free, with no build step and no server to set up.

Host a file free →