tags:

views:

177

answers:

7

For Example

Writing red is more efficient than #cc0000. It's less characters, less space, and easier to remember.

Should we always prefer color code over names?

In multi-developer environment.

Edit:

Over the last few years, all of the major browsers have included support for a special set of 140 colors that are recognized by their color name within HTML or CSS code.

This means that rather than having to remember that the color orange is specified with the hex code “#FFA500″, you can simply type the word “orange” when specifying a color in your code and the browser will automatically translate it to its hex code.

refrence - http://www.colorschemer.com/blog/2007/07/24/140-named-colors/

A: 

I think color names are more descriptive... And this is a good reason for using it when possible.

Jonathan
+8  A: 

Different browsers may not agree on what some color names mean. There are not names for all 16 million 24-bit colors. In fact there are only 17 W3C-standard color names. It's probably OK to use those.

Personally I use a templating system at build time to pre-process my CSS files, so that I can keep a standard set of site colors and refer to them by name. That way I get the best of both worlds: I know exactly what my RGB color values are, but I can use simpler names in the CSS.

(Of course, it's still not possible to know exactly how a color will look on a given user's browser.)

Pointy
CSS 2.1 defines the names and values of 17 colors: http://www.w3.org/TR/CSS2/syndata.html#value-def-color (orange was added in 2.1). I tend to use color names when one is available.
Francis Gagné
Thanks - serves me right for quoting w3schools without checking a real authority first (they forgot "orange") - answer fixed.
Pointy
i think it has also old info http://www.morecrayons.com/palettes/colorNames/w3c.php
metal-gear-solid
And what about this list http://www.crockford.com/wrrrld/color.html ? and this http://www.somacon.com/p142.php Do you mean all browser will render same color for 17 W3C colors , and for other color names it's not a gurantee?
metal-gear-solid
That is exactly right. It's not a standard, so you're taking a risk by relying on it. Now, you're free to do so, and of course you can test the colors that you actually use.
Pointy
@Pointy- and non w3c color names can create problem in css validation?
metal-gear-solid
Well they're not strictly-valid CSS. The color names in the W3C spec are just those 17, plus the "system color" names that refer to colors of system-supplied graphical elements. I don't know whether validators really complain about that however.
Pointy
Point- this article says it will not a problem with other colors http://www.colorschemer.com/blog/2007/07/24/140-named-colors/ will try with validators.
metal-gear-solid
Well it's your website, so you code up your colors however you like :-) In my experience, none of the colors in my current site (other than "black" and "white") are in the list anyway.
Pointy
A: 

in my opinion it's a matter of preference. if the color is as simple as red, black, grey, blue, white etc. ill use the word instead of the hex.

centr0
+2  A: 

I prefer a further optimization, #c00 for red. If you are going to use a primary color, or any color that is similar to #aabbcc, you can use shorthand, #abc.

Stephen
but red is easy to remember specially in multi-developer environment
metal-gear-solid
Efficiency is a relative term! if making things easier to remember improves your development efficiency, go for it! If it's bandwidth you're trying to optimize, use the shorthand.
Stephen
+1  A: 

It really comes down to your coding style. I stick to hex values for consistency - a color is always formatted as #000 or #000000, and I don't have to worry about switching between namd and unnamed colors.

In the end, it's a decision you and your team will have to make on your own. It's all about your preferences.

derekerdmann
A: 

Personally, I prefer all colours in a CSS file to be defined in the same way, if possible.

That way I don’t have to think in a different way when I see different colours defined (e.g. red, #cd876f and rgba(255,255,0,0.4)).

I also prefer colour notations that match what I’ll see when identifying the colour in the design I’m implementing. Photoshop’s colour palette gives RGB and hex values, amongst others, but doesn’t give CSS colour names. (Other design tools might do though.)

Paul D. Waite
+2  A: 

personally, i prefer using hexcodes because of 2 reasons

  1. it's easier to copy a hexcode from Photoshop
  2. you can use hexcodes throughout a stylesheet but you'll have to mix two styles (hexcodes and color names) otherwise. so your stylesheet can be more uniform/consistent.

This assumes you're using colors other that the simple red, black, white etc. In a multi-developer environment, i'd say hexcodes are better because they're more universally consistent (every developer knows exactly what the color is).

pixeltocode
+1 your thoughts are good
metal-gear-solid
@metal-gear-solid, thank you :)
pixeltocode