RGB or HEX for color
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
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.
Typically, you can copy hex value from graphics editor directly (from one text field) while 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.
Unfortunately, we are currently forced to use RGB notation in rgba()
function since CSSWG has not specced a way to specify RGBA values via hex notation, but nothing forces us to use functional ( rgb()
) notation if we don't need alpha transparency.
Update: 8-digit hexadecimal notation #RRGGBBAA
and #RGBA
(e. g. #00ffaa80
is equivalent to rgba(0, 255, 170, .5)
) is specced in the CSS Color Module Level 4 draft and implemented in Firefox 49. Unfortunately, while there are patches for other engines such as Chromium and WebKit, stable versions of all non-Gecko-based browsers do not actually support the feature (WebKit has it formally implemented since 2015-11-04, but in fact the feature is not available at least in Safari 9.1 and iOS 8.3), so Firefox is currently the only available implementation, and such notation cannot yet be used in the wild, though can be used in Firefox extensions.
HEX is stable for an enterprise service. It's easy to maintenance(preprocessor and work peole firiendly), 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.
链接地址: http://www.djcxy.com/p/15346.html下一篇: RGB或HEX颜色