A library for working with the color formats defined by HTML and CSS.
Project description
webcolors is a module for working with and converting between the various HTML/CSS color formats.
Support is included for normalizing and converting between the following formats (RGB colorspace only; conversion to/from HSL can be handled by the colorsys module in the Python standard library):
Specification-defined color names
Six-digit hexadecimal
Three-digit hexadecimal
Integer rgb() triplet
Percentage rgb() triplet
For example:
>>> import webcolors
>>> webcolors.hex_to_name("#daa520")
'goldenrod'
Implementations are also provided for the HTML5 color parsing and serialization algorithms. For example, parsing the infamous “chucknorris” string into an rgb() triplet:
>>> import webcolors
>>> webcolors.html5_parse_legacy_color("chucknorris")
HTML5SimpleColor(red=192, green=0, blue=0)
Full documentation is available online.
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
File details
Details for the file webcolors-24.11.1.tar.gz
.
File metadata
- Download URL: webcolors-24.11.1.tar.gz
- Upload date:
- Size: 45.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ecb3d768f32202af770477b8b65f318fa4f566c22948673a977b00d589dd80f6 |
|
MD5 | f348b16613d82426ae01e62375158a1a |
|
BLAKE2b-256 | 7b29061ec845fb58521848f3739e466efd8250b4b7b98c1b6c5bf4d40b419b7e |
File details
Details for the file webcolors-24.11.1-py3-none-any.whl
.
File metadata
- Download URL: webcolors-24.11.1-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 515291393b4cdf0eb19c155749a096f779f7d909f7cceea072791cb9095b92e9 |
|
MD5 | 0c77d42f8d3362064ea0439528affdcf |
|
BLAKE2b-256 | 60e8c0e05e4684d13459f93d312077a9a2efbe04d59c393bc2b8802248c908d4 |