Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS - RGB or HEX for color [duplicate]

Tags:

css

Possible Duplicate:
Are there any good reasons for using hex over decimal for RGB colour values in CSS?

Should one use RGB or HEX for colors in CSS style sheets?

If one is favored more than the other, why?

Is there a difference for future proofing, speed of processing, better compatibility between platforms/browsers etc

like image 577
StudioTime Avatar asked Mar 21 '12 10:03

StudioTime


People also ask

Should I use hex or RGB CSS?

When it comes to animating colors, working in RGB or HSL is preferable over HEX simply because numbers are easier to edit dynamically.

When would you use RGBA instead of a hex value for a color?

RGBA (Red, Green, Blue, Alpha) is used for making a colour transparent. The value for A (alpha) is from 0, completely transparent, to 1 completely opaque. hex, is a more recent quick easy value used exclusively for websites and applications.

Should I use HSL or RGB?

Formats like RGB and Hex are more machine-readable than human-readable. HSL, the opposite, is meant to be understandable by humans better. HSL is a more recent and spontaneous way to work with colors.

Does CSS use hex color?

The most common way to specify colors in CSS is to use their hexadecimal (or hex) values. Hex values are actually just a different way to represent RGB values. Instead of using three numbers between 0 and 255, you use six hexadecimal numbers.


1 Answers

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.

like image 107
Christofer Eliasson Avatar answered Oct 27 '22 11:10

Christofer Eliasson