What is the native representation for colors in modern web browser engines?

What is the native representation for colors in modern web browser engines?

Specifically:

Do they use hex (e.g. #123456), color names (e.g. ‘black’), RGB, HSL, or something else?

If the representation differs by different engines, please indicate. Also, if it differs if alpha is specified, please also indicate.

Add Comment
2 Answer(s)

If its a basic color name, then you can just say it. Go to the CSS page and type:

.a-class {     color:black;     color:rgb(0, 0, 0);  } 

etc.

Add Comment

Most browsers don’t care if you use names, hex codes, RGB, or HSL for fully opaque colors. Pick the one that makes the most sense for your use case.

Eg if you’re doing a quick prototype use names, if you need to do lots of color transforms use HSL. If you need transparency you must use RGBA or HSLA notation.

Be aware that browser makers get to decide what actual color is produced when you ask for teal or red so if you’re working with specific brand colors Hex/RGB/HSL is likely better.

To the best of my knowledge all browsers represent CSS colors the same way (this wasn’t always the case). Note: different screen calibrations will make colors appear different on individual devices)

However, color in images is very different and based on the browser, OS, device (display abilities), and embedded color profiles.

Edit: Browser engines to the best of my knowledge are converting to sRGB colorspace as that’s the display output of 99% of places where browsers run.

Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.