You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
James Bennett 58456d0b21 Fix typo in GH actions config. 1 month ago
.github/workflows Prep a release. 1 month ago
docs Prep a release. 1 month ago
src Prep a release. 1 month ago
tests Tox config update and GitHub Actions. 2 years ago
.gitignore Project-template syncing. 2 years ago
LICENSE Prep a release. 1 month ago
MANIFEST.in Reorg. 3 years ago
README.rst Add CI URL to badge. 2 years ago
setup.cfg Prep a release. 1 month ago
setup.py Prep a release. 1 month ago
tox.ini Fix typo in GH actions config. 1 month ago

README.rst

CI status image

webcolors is a module for working with HTML/CSS color definitions.

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(u'#daa520')
u'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(u'chucknorris')
HTML5SimpleColor(red=192, green=0, blue=0)

Full documentation is available online.