syntax for colors - head? body?

liunx

Guest
(sometimes I think I'm a body without a head <g>)

I thought you could define colors using a hex code. You apparently can do that for links, active links, visted links. What about hover? I want to put a hover color in my .css file.

I tried to put one in the <body style= .... area that NVU generated when I started a page from scratch, but w3c complained loudly!

Here is what NVU put in for me at the beginning of my body, right after the </head> (close).

<body style=
"color: rgb(51, 51, 51); background-color: rgb(192, 192, 192); direction: ltr;"
link="#3300CC" alink="#FFFF00" vlink="#990033">


Oh, my. I had to go into my Paint Shop Pro and use the Materials palette to find out what these colors are. Odd; if I can see a hex code, I can look up the color somehow (say, in a listing of web-safe colors that shows colors with hex codes).

Paint Shop Pro (v.8) kindly identified rgb(51, 51, 51) as hex #333333. It identified rgb(192, 192, 192) as #c0c0c0; that surprised me for some reason.

How come I can't use the hex code? I don't know why I find a hex code easier to cope with than a long rgb statement, but I do.

And I don't understand why hex codes are allowed for links, but not for - uh - backgrounds?

I added to the end of the link series:

"hover="#00ccff";

and promptly got a complaint from HTML-kit that "hover" is a proprietary something-or-other; I'm too disoriented to remember just what that message was, sorry.

Anyway, HTML-kit identified my attempt as an error or warning; I can't even remember which!

Right now, all my html documents have that <body style=.... statement I showed above, but I'd like to take it out of there, and put it in an external .css file instead. Yet from what FrozenDice said, I gather the syntax in the external file would be the same as in the embedded statement. So am I stuck with the rgb designation, instead of hex codes, for - uh - background color?

And here's another thing that confuses me mightily.

What does "color" refer to in that <body style= .... statement? The best I can seem to guess is that it refers to the color used for text? and perhaps for anything else that isn't specifically defined as a link - or for hover?

(anybody who can understand my questions deserves a medal.)

Mon, 06 Dec 2004 18:56:01 (PST)Whoah, whoah, let's break this down. For colors, you have, to my knowledge, three choices of defining the same colour.

body {
color:red;
}

body {
color:#ff0000;
}

body {
color:rgb(255, 0, 0);
}

All produce the same affect. I personally use hex, since I'm not too trusting of named colours, and I'm not fond of rgb. But, the difference between hex and rgb should not be decipherable.


Not all your styles go in the style attribute of your body tag! All your styles for the body element go in there. So, if you had this in a CSS document:

body {
background:#ffffff;
color:#000000;
font-family:Arial, sans-serif;
}

You could instead do this:

<body style="background:#ffffff;color:#000000;font-family:Arial, sans-serif;>

Which would have the same affect. Links, however, are their own element. So, you could do this:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<html lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="Content-Style-Type" content="text/css">
<title></title>
<style type="text/css">
<!--
body {
background:#0000000;
color:#ffffff;
}

A:link { color:#0000ff; }
A:hover { color:#ff0000; }
A:active { color:#ff0000; }
A:visited { color:#0000ff; }
-->
</style>
</head>
<body>

</body>
</html>


You shouldn't be using the link, alink, vlink attributes, since they are presentational markup. Avoid them. Use CSS instead, it's much prefferred.I didn't notice if Bob said but "color" means "foreground color", i.e. the default color for text.

BTW, the set of colors with "doubled" hex digits like #33aaff are called "web safe colors" and they can be short-handed (any noun can be verbed) with three digits like #3af.My weakness in knowledge are showing; I hardly know what a property is, or a selector, or - an attribute! I can sort of guess, and will learn in time, but thanks for the remarks on color and hex values; I too prefer the hex; it's so specific-seeming in a single small declaration.

Oh! Color means foreground color! Wow! (therefore, text; amazing).

I read in w3schools that color names might not be understood by all browsers, and I prefer to keep things as simple - and universal - as possible, so will do what I can to stick with the hex definitions for color.

Presentational? I was wondering waht alink, vlink, and so forth, meant, and why the form or usage seemed to be different from one example to another. Now I know there's a word to mean a difference: presentational, haha!

Okay; I'll avoid that, and use your examples to help me out.

It take a really brave, considerate, and kind person to try to answer my questions, and I appreciate all your help more than you can imagine!

I'd better lay off for the day so there'll be anything left of my brain in the morning. My dogs say so, too, and so does my cat.

Thank you all so much!

Mon, 06 Dec 2004 20:44:03 (PST)
 
Back
Top