Colors Values in CSS

CSS has several different variations for specifying color. They are HEX (long and shorthand), Color Keywords, RGB, RGBA, HSA, HSLA.


/* Hex - short */
color: #ddd;

/* Hex - long */
color: #F04530;

/* Color Keyword */
color: red;

/* RGB */
color: rgb(255,255,255);

/* RGBA */
color: rgba(200, 54, 54, 0.5);

/* HSL */
color: hsl(166, 92%, 50%)

/* HSLA */
color: hsla(128, 42%, 50%, 0.61)

Note: Some browsers don’t like RGBA, HSL and HSLA. Use with caution.

Jake Bresnehan

A Front End Developer based in Sydney and the creator of Web Design Weekly.

Web Design Weekly keeps developers at the forefront of techniques and trends whilst helping them learn and grow to produce top quality code to make the web a better place for all.

This post currently has no responses. What do you think?

You can use basic HTML when posting code, please turn all < characters into &lt; or > into &gt;
If the code is multi-line, use <pre><code></code></pre>

Leave a Reply

Your email address will not be published. Required fields are marked *

Current day month ye@r *