Inline CSS Checker
Short answer
Count the inline style attributes and style blocks on a page, see their total size and example elements, and learn how to move them into a stylesheet.
What it does not do: It reads the HTML as delivered, so styles that scripts or CSS-in-JS add while the page runs are not counted, and external stylesheets are not checked.
What It Does
Finds every inline style="" attribute and <style> block on your page. Reports how many there are and their total size, shows up to 8 example elements with their CSS, and suggests how to move the styles into a stylesheet.
Why It Matters
Inline style attributes cannot be cached separately, are hard to maintain and are blocked by a strict Content-Security-Policy unless you allow them explicitly. The exception is critical above-the-fold CSS in a <style> block, which can help the first render.
How It Works
-
Enter a page URL or paste its HTML
-
We fetch the page HTML and parse every <element style="">
-
Count inline style attributes separately from inline `<style>` blocks
-
Return the total inline CSS size, up to 8 example elements and refactoring advice
Sample input + output
pasted HTML: a sale page made with a page builder
<style>.btn{padding:12px 20px;border-radius:8px}</style>
<style>.hero{background:#0ea5a4;color:#fff}</style>
<section class="hero" style="padding:48px 24px;text-align:center">
<div class="card" style="border:1px solid #e2e8f0;padding:16px">Trail shoes</div>
<footer style="margin-top:32px;font-size:13px;color:#64748b"> Score: 67/100 — Some inline CSS — worth moving to a stylesheet. Inline style attributes: 9 Embedded style blocks: 2 Inline CSS size: 429 B Top inline-styled elements: <section.hero style="padding:48px 24px;text-align:center"> <h1 style="font-size:40px;margin:0 0 12px"> <p style="font-size:18px;opacity:.9"> <a.btn style="background:#2e5bff;color:#fff;display:inline-block"> <div.grid style="display:grid;grid-template-columns:repeat(3,1fr);gap:16px"> <div.card style="border:1px solid #e2e8f0;padding:16px"> <div.card style="border:1px solid #e2e8f0;padding:16px"> <div.card style="border:1px solid #e2e8f0;padding:16px">
How to read the result
- Score (67) and headline
- A summary of how much styling sits in the HTML instead of a stylesheet. Up to 3 style attributes and one <style> block count as clean; 4 to 20 attributes give "Some inline CSS — worth moving to a stylesheet"; more than 20 count as heavy.
- Inline style attributes (9)
- Elements that carry their own style="" attribute. These are the ones to move first: the same rules repeat on every element and every page, the browser cannot cache them separately, and a strict Content-Security-Policy blocks them unless inline styles are allowed.
- Embedded style blocks (2)
- How many <style> elements the page has. One block with the CSS the first screen needs is a recognised technique and counts as clean; several blocks usually come from plugins or widgets that each add their own.
- Inline CSS size (429 B)
- The characters in all style attributes and <style> blocks together. One large block does not lower the score, so read this figure too: tens of kilobytes of CSS inlined on every page are downloaded again with each page instead of being cached once.
- Top inline-styled elements
- Up to 8 elements with their style attribute, in page order and shortened to 60 characters. Repeated lines, like the three identical cards in the sample, are the easiest to turn into one class.
Who Uses This
-
Frontend Developer
Audit a legacy site for inline-style cleanup — extract patterns to utility classes to enable proper caching.
-
Security Engineer
Pre-CSP-deployment audit — every inline `style=""` blocks `style-src 'self'` policy. Extract them to enable strict CSP.
-
Performance Engineer
Inline CSS adds bytes to every HTML response. Move repeated patterns to a cached stylesheet — wins on every subsequent page load.
Common problems and how to fix them
-
The same style repeated on many elements
Give the elements a class and write the declarations once in your stylesheet. In the sample the three cards share border and padding: one .card rule replaces three attributes.
/* stylesheet */ .card { border: 1px solid #e2e8f0; padding: 16px; } <!-- HTML --> <div class="card">Trail shoes</div> -
Markup from a page builder
Most builders have a setting that writes styles to a generated stylesheet instead of the HTML, often called the CSS print method or external file. Turn it on and check the page again.
-
A strict Content-Security-Policy blocks the styles
With style-src 'self' every style="" attribute is refused. Move them to classes; if a few must stay, allow just those with 'unsafe-hashes' and their hashes instead of opening 'unsafe-inline' for the whole site.
-
Several <style> blocks from plugins
Merge them into the theme stylesheet, or let your optimisation plugin combine them. Keep at most one inline block, for the CSS the first screen needs.
-
One very large inline <style> block
Inlining the critical CSS helps the first paint, but inlining a whole framework stylesheet on every page makes visitors download it again with each page. Keep only the first-screen rules inline and load the rest from a cached file.
Frequently Asked Questions
- Is inline CSS bad for SEO?
- Not directly. It makes pages heavier and harder to maintain, and it gets in the way of a strict Content-Security-Policy.
- When is inline CSS appropriate?
- Critical above-the-fold styles in `<style>` tags (not `style=""` attributes), and dynamic per-component values that genuinely vary at runtime.
- How do I refactor inline styles?
- Identify repeated patterns → extract to utility classes → add to your stylesheet → replace inline `style=""` with `class=""`.
- Does this break CSP?
- Yes — strict CSP (`style-src 'self'`) blocks inline `style=""`. You'd need `'unsafe-inline'` or `'unsafe-hashes'` to allow it.
- What about CSS-in-JS frameworks?
- Many add <style> tags or style attributes while the page runs, which this tool does not see because it reads the HTML as delivered. Most can extract static CSS at build time, which is the better choice for production.
Sources
The documentation this tool and the explanations on this page are based on.
- style (HTML global attribute) — MDN Web Docs
- <style>: The Style Information element — MDN Web Docs
- Content-Security-Policy: style-src directive — MDN Web Docs
- Extract critical CSS — web.dev