--- id: css-inline version: "0.21.1" license: unclear license_treatment: permissive maintenance: active --- # css-inline — High-performance library for inlining CSS into HTML 'style' attributes License: permissive · Maintenance: active · Downloads: 3.1M/mo ## 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 above — 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 pip install css-inline uv add css-inline poetry add css-inline ## Installing 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 = "

Text

" 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_current - Install friction: medium - Maintenance: active - Downloads: 3.1M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags css inlining for html, inline css into html, email html css inlining, style attribute generation, css to inline styles, html email preparation, stylesheet inlining tool, email-html, css-processing [View on SkillFed](https://skillfed.io/packages/css-inline) · [View on PyPI](https://pypi.org/project/css-inline/)