Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Color vs Hex Codes?

0 views
Skip to first unread message

andrew

unread,
Apr 26, 2007, 11:12:13 PM4/26/07
to
Hi,

I understand that when writing a css and specifying color I can use
the following color _names_:

aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive,
purple, red, silver, teal, white, and yellow

What I don't fully understand is the pros and cons of using these
simple descriptions rather than the vaster list of hex codes.
Although the obvious 'pro' of greater choice is obvious :-)

Can anybody point me in the right direction?

Andrew

--
Andrew's Corner
http://people.aapt.net.au/~adjlstrong/

Nik Coughlin

unread,
Apr 26, 2007, 11:50:51 PM4/26/07
to
andrew wrote:
> Hi,
>
> I understand that when writing a css and specifying color I can use
> the following color _names_:
>
> aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive,
> purple, red, silver, teal, white, and yellow
>
> What I don't fully understand is the pros and cons of using these
> simple descriptions rather than the vaster list of hex codes.
> Although the obvious 'pro' of greater choice is obvious :-)

For one thing, it's easier to remember a color name than a hex code. Sure
it's easy to remember that #000 is black or #fff is white, #f00 red etc. but
do you remember off the top of your head that teal is #008080, that olive is
#808000 and so forth? Also for some reason I find it easier to type words
than numbers, so I tend to use white/black/red/blue etc in place of hex
codes when I use those colors. But because I can't be bothered checking
browser support I try and restrict it to ones that I know will work, like
the aforementioned.


dorayme

unread,
Apr 27, 2007, 12:12:56 AM4/27/07
to
In article <20070427131213....@nospam.invalid>,
andrew <and...@nospam.invalid> wrote:

> Hi,
>
> I understand that when writing a css and specifying color I can use
> the following color _names_:
>
> aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive,
> purple, red, silver, teal, white, and yellow
>
> What I don't fully understand is the pros and cons of using these
> simple descriptions rather than the vaster list of hex codes.
> Although the obvious 'pro' of greater choice is obvious :-)
>
> Can anybody point me in the right direction?
>

About the only worry of using colour names is being sure all the
browsers that are used to view your site will understand them.
There is little doubt with hex.

--
dorayme

Gérard Talbot

unread,
Apr 27, 2007, 1:16:48 AM4/27/07
to
andrew wrote :

> Hi,
>
> I understand that when writing a css and specifying color I can use
> the following color _names_:
>
> aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive,
> purple, red, silver, teal, white, and yellow
>

... and orange in CSS 2.1

> What I don't fully understand is the pros and cons of using these
> simple descriptions rather than the vaster list of hex codes.
> Although the obvious 'pro' of greater choice is obvious :-)

You're limited to 17 colors with reserved color names and you're not
with hexadecimal values. On the other hand, color names are easy to
figure out, the code becomes more intuitive, easier to maintain.

In CSS 3, there is some 300+ color names.

Overall, I prefer to always use color names.

Gérard
--
Using Web Standards in your Web Pages (Updated Dec. 2006)
http://developer.mozilla.org/en/docs/Using_Web_Standards_in_your_Web_Pages

Mark

unread,
Apr 27, 2007, 3:38:39 AM4/27/07
to
andrew wrote:
> Hi,
>
> I understand that when writing a css and specifying color I can use
> the following color _names_:
>
> aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive,
> purple, red, silver, teal, white, and yellow
>
> What I don't fully understand is the pros and cons of using these
> simple descriptions rather than the vaster list of hex codes.
> Although the obvious 'pro' of greater choice is obvious :-)
>
> Can anybody point me in the right direction?
>
> Andrew
>
Technically, only 16 colours have been defined, with all the rest a
convenient tradition. This means that there is no guarantee that any but
the most basic colours will be rendered the same by all colours. This is
particularly true of the more esoteric colours. However, the tradition
is a strong one, and probably reliable enough.

On the other hand, specifying the hex (or rgb(...,...,...)) is available
for all colours, defined or not, and may be the only way of matching
your specific colours.

If you want to be sure, you might check out W3School's list
(http://www.w3schools.com/css/css_colornames.asp) and use the provided
RGB or hex values.

Mark


Jukka K. Korpela

unread,
Apr 27, 2007, 6:15:45 AM4/27/07
to
Scripsit Mark:

> Technically, only 16 colours have been defined,

You mean colour names. There's a difference between a colour and its name.

> On the other hand, specifying the hex (or rgb(...,...,...)) is
> available for all colours, defined or not, and may be the only way of
> matching your specific colours.

Matching colours is the point.

When you design a colour scheme, you should use a good program that lets you
preview the effects of colour combinations and tune the colours
interactively. Don't forget to use tools for checking the colour contrasts
as well. When you are satisfied, you simply pick up the hexadecimal values
that the program shows you and copy them into your CSS code. Some colours
might, by accident, be colours that have names in (some version of) CSS, but
there's little need to use those names. The mnemonic names (which don't
really tell which particular colour is used - e.g., "blue" means different
things to different people) would actually mess up the CSS code when used in
a context where most colours are indicated by hex codes.

If you're not creating a real page but just playing or testing, it's ok to
use names like red (denoting the pure bright red colour that one should
rarely use on real pages) for simplicity.

> If you want to be sure, you might check out W3School's list

If you want to be sure, don't _check_ anything at w3schools.com, which has
been found to contain many errors. The _specifications_ are at
http://www.w3.org

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Bergamot

unread,
Apr 27, 2007, 9:35:31 AM4/27/07
to
dorayme wrote:
> In article <20070427131213....@nospam.invalid>,
> andrew <and...@nospam.invalid> wrote:
>
>> aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive,
>> purple, red, silver, teal, white, and yellow
>
> About the only worry of using colour names is being sure all the
> browsers that are used to view your site will understand them.

Um, those 16 names have been used since HTML 3.2, maybe earlier. It's
extremely unlikely a browser won't recognize them. How the display
device handles color is another matter, but irrelevant.

--
Berg

Mark

unread,
Apr 27, 2007, 7:17:12 PM4/27/07
to
Jukka K. Korpela wrote:
> Scripsit Mark:
>
>> Technically, only 16 colours have been defined,
>
> You mean colour names. There's a difference between a colour and its name.

Yes, I mean colour names.


>
>> On the other hand, specifying the hex (or rgb(...,...,...)) is
>> available for all colours, defined or not, and may be the only way of
>> matching your specific colours.
>
> Matching colours is the point.
>
> When you design a colour scheme, you should use a good program that lets
> you preview the effects of colour combinations and tune the colours
> interactively. Don't forget to use tools for checking the colour
> contrasts as well. When you are satisfied, you simply pick up the
> hexadecimal values that the program shows you and copy them into your
> CSS code. Some colours might, by accident, be colours that have names in
> (some version of) CSS, but there's little need to use those names. The
> mnemonic names (which don't really tell which particular colour is used
> - e.g., "blue" means different things to different people) would
> actually mess up the CSS code when used in a context where most colours
> are indicated by hex codes.
>

Not Quite. Blue may mean different things to different people, but the
colour named Blue has been specified, so it is safe to use, even if you
don't like it. And it doesn't really matter what it means to other
people, as long as the browsers agree.

> If you're not creating a real page but just playing or testing, it's ok
> to use names like red (denoting the pure bright red colour that one
> should rarely use on real pages) for simplicity.
>
>> If you want to be sure, you might check out W3School's list
>
> If you want to be sure, don't _check_ anything at w3schools.com, which
> has been found to contain many errors. The _specifications_ are at
> http://www.w3.org
>

A little bit unfair. The list at w3schools is nevertheless helpful, and
will work on the most common browsers. The specifications at w3 do not
extend to these additional colours.

However, the point remains that if you are trying to match colours
precisely, you are better off using their rgb or hex values.

Mark

Jukka K. Korpela

unread,
Apr 28, 2007, 3:15:16 AM4/28/07
to
Scripsit Mark:


>> The mnemonic names (which don't really tell which particular
>> colour is used - e.g., "blue" means different things to different
>> people) would actually mess up the CSS code when used in a context where
>> most
>> colours are indicated by hex codes.
>>
>
> Not Quite.

So you don't think that if dozens of colours are identified by their hex
codes in a style sheet, using a name for one colour or a few colours doesn't
actually mess up the style sheet a bit? In my opinion, it would be as messy
as specifying all margins using the mm unit (say, in a user style sheet for
printing) but one margin as 1.25in. It's formally correct and well-defined,
but messy. _That_ was my point above. My _secondary_ point was about the
mnemonic nature of names.

> Blue may mean different things to different people, but the
> colour named Blue has been specified, so it is safe to use, even if
> you don't like it. And it doesn't really matter what it means to other
> people, as long as the browsers agree.

The main argument in favor of using blue is that it is mnemonic and
descriptive to a person who reads CSS code. My argument against this was
that the word blue as such does not really describe the colour. You _need_
to know its definition as #0000ff in order to know what it really means. And
if you know that, you can also read CSS code with hex codes for colours.

The only remaining argument in favor of blue is the weak argument that it is
more convenient to write, and you might save a few milliseconds since you
don't need to recollect that you would need to type #00f. But this argument
can be turned around. If you really find the names more convenient to type,
then this will tempt you into using them just because they are there, i.e.
you will strongly favour the use of the sixteen (or seventeen) names
colours - most of which are too bright for use as text or background colours
or even as border colours.

>> If you want to be sure, don't _check_ anything at w3schools.com,
>> which has been found to contain many errors. The _specifications_
>> are at http://www.w3.org
>
> A little bit unfair.

It's not unfair at all to say that a site offered as a reference isn't
suitable as a reference when it is not reliable. To say "check out" means to
suggest use as a reference.

> The list at w3schools is nevertheless helpful,
> and will work on the most common browsers. The specifications at w3
> do not extend to these additional colours.

To the extent that this is true - and I haven't compared the lists in every
detail (have you?) - the w3schools site is still not useful as a reference,
since the authoritative specification is available elsewhere. If the
information is presented in an easier and perhaps more visual form, it would
be nice - if we could rely on the authors. But we cannot; we know that
w3schools contains many errors and wrong advice, and with its name, it
probably intentionally tries to give the impression of being endorsed by the
w3c.

> However, the point remains that if you are trying to match colours
> precisely, you are better off using their rgb or hex values.

My argument wasn't about any "precise" matching but about selecting
compatible colours in the first place - using some real colour design
instead of just throwing in some colour names.

Ben C

unread,
Apr 28, 2007, 4:32:49 AM4/28/07
to
On 2007-04-28, Jukka K. Korpela <jkor...@cs.tut.fi> wrote:
> Scripsit Mark:
>
>
>>> The mnemonic names (which don't really tell which particular
>>> colour is used - e.g., "blue" means different things to different
>>> people) would actually mess up the CSS code when used in a context where
>>> most
>>> colours are indicated by hex codes.
>>>
>>
>> Not Quite.
>
> So you don't think that if dozens of colours are identified by their hex
> codes in a style sheet, using a name for one colour or a few colours doesn't
> actually mess up the style sheet a bit? In my opinion, it would be as messy
> as specifying all margins using the mm unit (say, in a user style sheet for
> printing) but one margin as 1.25in. It's formally correct and well-defined,
> but messy.

The excessive desire for consistency is the hobgoblin of the small mind
(to quote various people slightly inconsistently).

Mixing blue and #dfedce is fine. Inches and mm a bit more pointless, but
why not? I've owned whole cars built with mixtures of inches and mm.

dorayme

unread,
Apr 28, 2007, 5:32:54 AM4/28/07
to
In article <slrnf361hi....@bowser.marioworld>,
Ben C <spam...@spam.eggs> wrote:

> On 2007-04-28, Jukka K. Korpela <jkor...@cs.tut.fi> wrote:
> > Scripsit Mark:
> >
> >
> >>> The mnemonic names (which don't really tell which particular
> >>> colour is used - e.g., "blue" means different things to different
> >>> people) would actually mess up the CSS code when used in a context where
> >>> most
> >>> colours are indicated by hex codes.
> >>>
> >>
> >> Not Quite.
> >
> > So you don't think that if dozens of colours are identified by their hex
> > codes in a style sheet, using a name for one colour or a few colours
> > doesn't
> > actually mess up the style sheet a bit? In my opinion, it would be as messy
> > as specifying all margins using the mm unit (say, in a user style sheet for
> > printing) but one margin as 1.25in. It's formally correct and well-defined,
> > but messy.
>
> The excessive desire for consistency is the hobgoblin of the small mind
> (to quote various people slightly inconsistently).
>

A tendency towards consistency can also be an indication of a
nobler zeal for beauty.

My car is like yours in the respect you mention below. Mixing the
standards of units in the components is a damn nuisance as it
complicates the size of the tool box and the decisions to be
made. On this one, I find Korpela's reasoning congenial. I also
agree with almost all his other reasons for the purer approach of
using hex. Especially his excellent point that an addiction to
colour names can be just that!

But I can't stop as I have to get back to my present project of
writing "Zen and the Art of HTML"


> Mixing blue and #dfedce is fine. Inches and mm a bit more pointless, but
> why not? I've owned whole cars built with mixtures of inches and mm.

--
dorayme

John Dunlop

unread,
Apr 28, 2007, 9:09:11 AM4/28/07
to
Mark:

> If you want to be sure, you might check out W3School's list
> (http://www.w3schools.com/css/css_colornames.asp) and use the provided
> RGB or hex values.

W3Schools is good for that game where you open a page and count how
many errors you can see. The person with the most is the winner.

--
Jock

0 new messages