Skip to main content

A library for working with the color formats defined by HTML and CSS.

Project description

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("#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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

webcolors-1.13.tar.gz (41.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

webcolors-1.13-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file webcolors-1.13.tar.gz.

File metadata

  • Download URL: webcolors-1.13.tar.gz
  • Upload date:
  • Size: 41.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for webcolors-1.13.tar.gz
Algorithm Hash digest
SHA256 c225b674c83fa923be93d235330ce0300373d02885cef23238813b0d5668304a
MD5 c9be30c5b0cf1cad32e4cbacbb2229e9
BLAKE2b-256 a1fbf95560c6a5d4469d9c49e24cf1b5d4d21ffab5608251c6020a965fb7791c

See more details on using hashes here.

File details

Details for the file webcolors-1.13-py3-none-any.whl.

File metadata

  • Download URL: webcolors-1.13-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for webcolors-1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 29bc7e8752c0a1bd4a1f03c14d6e6a72e93d82193738fa860cbff59d0fcc11bf
MD5 d9e9ac7c1da7a2b18975265cf0a953ac
BLAKE2b-256 d5e13e9013159b4cbb71df9bd7611cbf90dc2c621c8aeeb677fc41dad72f2261

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page