Skip to main content

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

Project description

https://travis-ci.org/ubernostrum/webcolors.svg?branch=master

webcolors is a Python (2.7, 3.4+) 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(192, 0, 0)

Full documentation is available online.

Project details


Release history Release notifications

This version
History Node

1.8.1

History Node

1.8

History Node

1.7

History Node

1.5

History Node

1.4

History Node

1.3.1

History Node

1.3

History Node

1.2

History Node

1.1

History Node

1.0

History Node

0.1

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
webcolors-1.8.1-py2.py3-none-any.whl (11.2 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Feb 12, 2018
webcolors-1.8.1.tar.gz (33.1 kB) Copy SHA256 hash SHA256 Source None Feb 12, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page