CSS - RGB or HEX for color

I believe that it is mostly a matter of personal taste whether you should use RGB or HEX. Personally I use HEX, because it feels more convenient - it is easier to scan when reading the code and easier to copy from your preferred image editor. Also for colors like white (#fff), black (#000) it could save you a few bytes (not that it would make much difference though).

In the end it is really just two different representations of the same thing, and from a performance perspective I don't think it matters. At least there are loads of other things you can do to increase performance, that will have a greater impact on performance.


HEX is stable for an enterprise service. It's easy to maintain (preprocessor and work people friendly), and many browsers are supported.

But, color-name is not bad if you like. It's fun to choose from the color palette, and many colors are defined already.

And so, it's an appendix. I'm using HLSA color pattern in my private experimental website now. see also if you have an interest to the new CSS3 draft: http://www.w3.org/TR/css3-color/ .It's very intuitive if you know the color rule of the nature phenomenon.


Typically, you can copy a hex value from a graphics editor directly — from a single text field. For RGB, you can’t: RGB values are usually represented via three separate text fields. So hex values are at least easier for everyday use.

But there was no way for a while to use hex notation for values with alpha transparency, so we were forced to use RGB notation via the rgba() function.

The CSS Color Module Level 4 draft spec adds the 8-digit hexadecimal notation #RRGGBBAA and #RGBA: e. g. #00ffaa80 is equivalent to rgba(0, 255, 170, .5). The feature is available in Firefox 49+, Chromium 62+ and Safari 10+ (WebKit bug), but neither in IE nor in Edge. According to caniuse, such notation is supported by 75% of browsers, so it probably cannot yet be used in the wild, though can be used in browser add-ons.


If its for devices (VGA etc) -> use RGBA values, otherwise HEX HSL and pretty much anything works.

Tags:

Css