Library and CLI application for inlining CSS rules from a set of stylesheets and applying them to an HTML file using `style` attributes.
Project description
inline-css
Inline-CSS is a Python module and CLI application for inlining CSS stylesheets by resolving their rules
and applying them directly to the HTML as style tags. For example, with the following HTML and CSS:
<div>
<p class="demo">Hello, world!</p>
</div>
.demo {
color: red;
}
The result would be:
<div>
<p style="color: red">Hello, world!</p>
</div>
Getting Started
This project uses uv; running uv sync and then uv run inline_css ought to do it! See below for usage instructions.
Usage
usage: inline-css [-h] [--verbose] [--out OUT | --outdir OUTDIR | --quash]
html css [css ...]
Inlines CSS rules within stylesheets and applies them to HTML files
positional arguments:
html Source HTML file
css Source CSS files
options:
-h, --help show this help message and exit
--verbose, -v Enable verbose output
--out OUT, -o OUT File to write HTML output to. Will be overwritten if
it already exists.
--outdir OUTDIR, -d OUTDIR
Directory to write HTML output to. Filename will be
same as the source file.
--quash Overwrite the original HTML file with the inlined
output. Very dangerous!
Limitations
From this library:
!importantis not currently respected. Occurrences of!importantare detected and logged as warnings.- Existing
styleattributes on HTML tags are quashed by CSS rules.
From consequences of running outside a browser, these selectors are accepted but never apply:
:hover:active:focus:target:visited
Other limitations:
Why?
If you don't know why you'd need this, you don't need this.
(There are some content platforms that allow custom HTML but don't allow custom stylesheets, despite requiring styling to be viable. This is to make life easier for content creators on those platforms.)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file inline_css-0.1.1.tar.gz.
File metadata
- Download URL: inline_css-0.1.1.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13b6a07c751ff16690a376d945997dd03fefbc947d930f2c9c8ce5223924e6eb
|
|
| MD5 |
2fb1f375b4d60bd05b409dac85f5c493
|
|
| BLAKE2b-256 |
df1349d61d6da3ef5f1f5318c6c12c2fb60d02cd876e044ff547dfbaaa321ce2
|
File details
Details for the file inline_css-0.1.1-py3-none-any.whl.
File metadata
- Download URL: inline_css-0.1.1-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cfc51f837e9aa2dc6680028552e9e77d30e85a4c5724ef0dbd5f246008daa2f
|
|
| MD5 |
e7dbe228378b8e46e892ea4927362739
|
|
| BLAKE2b-256 |
7c2c72538ab11e647cb1f73a50e90da49151887576b267ed143f6659010235c5
|