css-inline
High-performance library for inlining CSS into HTML 'style' attributes
What it is and what it does
css_inline is a high-performance library that transforms CSS rules from style and link tags into inline style attributes on HTML elements. It's built on Mozilla's Servo project components and is designed for scenarios like preparing HTML emails or embedding HTML into third-party web pages where external stylesheets cannot be used. The library handles CSS resolution, can load external stylesheets (including from the filesystem), and optionally caches them to reduce repeated network requests.
It offers both simple one-shot functions (inline, inline_fragment) and batch processing (inline_many, inline_many_fragments) for concurrent document processing. Configuration options let you control whether to keep or remove style/link tags, minify CSS, apply width/height attributes, and skip inlining for specific elements via data attributes. It supports HTML5 and CSS3, works on Linux, Windows, macOS, and in the browser via PyOdide, and is tested on CPython 3.10–3.14 and PyPy 3.11.
Use it for:
- Prepare HTML emails by inlining all CSS so styles render correctly in email clients that strip external stylesheets.
- Embed HTML snippets into third-party web pages where external CSS links are not allowed or would conflict.
- Batch-process multiple HTML documents concurrently to improve throughput when generating many styled documents.
- Generate responsive emails by keeping @media queries in style tags while inlining base styles into elements.
- Load and cache stylesheets from the filesystem or remote URLs to avoid repeated network requests during bulk HTML generation.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Inlines CSS from style and link tags directly into HTML element style attributes, transforming external stylesheets into inline styles suitable for email and embedded HTML contexts.
Yes. The package is actively maintained, has no known vulnerabilities, supports current Python versions (3.10+), and solves a specific and common problem (CSS inlining for email and embedded HTML) with a permissive license. Medium install friction is acceptable given the availability of pre-built wheels for most platforms. Suitable for production email systems and HTML embedding workflows.
Install
css-inline on PyPI
pip
pip install css-inlineuv
uv add css-inlinepoetry
poetry add css-inlineInstalling css-inline
Before you install
Medium install friction due to compiled Rust bindings, but pre-built wheels cover most common platforms (Linux, macOS, Windows, WebAssembly). Requires Rust 1.65+ only if building from source on unsupported platforms. Active maintenance with a release 6 days ago.
License in practice
Licensed under MIT (permissive), allowing unrestricted use, modification, and distribution in both open-source and proprietary projects.
Quickstart
pip install css_inline
import css_inline
HTML = "<style>h1 { color: blue; }</style><h1>Text</h1>"
inlined = css_inline.inline(HTML)
Requires Python 3.10 or higher; pre-built wheels available for most platforms, but Rust 1.65+ needed to build from source on unsupported architectures.
Verify before relying
- Whether the 10-500x performance claim versus alternatives is independently verified or measured under specific conditions.
- Whether stylesheet caching actually reduces network overhead in typical email-generation workflows.
- Whether parallel processing via inline_many provides measurable speedup on typical multicore systems.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 6 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,143,174/month — #2,730 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: css_inline-0.21.1-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl; css_inline-0.21.1-cp310-abi3-macosx_10_12_x86_64.whl; css_inline-0.21.1-cp310-abi3-manylinux_2_12_i686.manylinux2010_i686.whl; css_inline-0.21.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; css_inline-0.21.1-cp310-abi3-manylinux_2_24_aarch64.whl; css_inline-0.21.1-cp310-abi3-manylinux_2_24_armv7l.whl; css_inline-0.21.1-cp310-abi3-musllinux_1_2_aarch64.whl; css_inline-0.21.1-cp310-abi3-musllinux_1_2_armv7l.whl; css_inline-0.21.1-cp310-abi3-musllinux_1_2_x86_64.whl; css_inline-0.21.1-cp310-abi3-pyemscripten_2025_0_wasm32.whl; css_inline-0.21.1-cp310-abi3-win32.whl; css_inline-0.21.1-cp310-abi3-win_amd64.whl; css_inline-0.21.1-pp311-pypy311_pp73-macosx_10_12_x86_64.whl; css_inline-0.21.1-pp311-pypy311_pp73-manylinux_2_24_aarch64.whl; css_inline-0.21.1-pp311-pypy311_pp73-manylinux_2_24_x86_64.whl
Keywords: css, html, email, stylesheet, inlining
Tags
More HTML packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
beautifulsoup4Beautiful Soup parses HTML and XML documents…
permissive · top 100 on PyPI
lxmllxml provides Python bindings to libxml2 and…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
MarkdownConverts Markdown text to HTML using a Python…
permissive · top 1,000 on PyPI
pynlinerConverts CSS stylesheets to inline styles in…
permissive · top 15,000 on PyPI
django-premailerA Django template tag that converts CSS blocks…
permissive · top 15,000 on PyPI
premailerConverts CSS style blocks into inline style…
permissive · top 5,000 on PyPI
email-toWraps Python's standard email modules to…
permissive · top 15,000 on PyPI
emailsBuild and send HTML and plain-text emails with…
permissive · top 15,000 on PyPI
cssutilscssutils parses and builds CSS stylesheets as a…
copyleft · top 5,000 on PyPI
html-textExtracts plain text from HTML while filtering…
permissive · top 5,000 on PyPI
dict2cssdict2css converts Python dictionaries to CSS…
permissive · top 15,000 on PyPI
html-for-docxConverts HTML content to Word documents…
permissive · top 15,000 on PyPI
mrmlConverts MJML (a markup language for responsive…
unclear · top 5,000 on PyPI