Which has priority?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I have a color attribute set in the body part of my style sheet. This
style sheet is included in the HTML file by the usual

<link href="css/dp.css" rel="stylesheet" type="text/css" />

For some reason, I need some specific pages to use a different text color
for the entire body, I therefore have the following line

<body bgcolor="black" color="#00ffcc" onload="init()">

(The JS is a bog standard NS4 hack to resize the viewing window - it can
be safely ignored)

The color though remains the same as the one defined in the style sheet.

Shouldn't the color defined in the body element of the HTML take priority over
that of the stylesheet?



Re: Which has priority?

Paul F. Johnson wrote:
Quoted text here. Click to load it

Obviously not :-). Check out the cascading rules:

"6.4.4 Precedence of non-CSS presentational hints
The UA may choose to honor presentational hints from other sources than
style sheets, for example the FONT element or the "align" attribute in
HTML. If so, the non-CSS presentational hints must be translated to the
corresponding CSS rules with specificity equal to zero. The rules are
assumed to be at the start of the author style sheet and may be
overridden by subsequent style sheet rules. "

So what you need to do is create a second style rule. For example, you
could use an id selector for those 'specific' pages in your stylesheet:

body {your usual styles}
body#specificpage {background-color:black; color:#00ffcc;}

<body id="specificpage">


Site Timeline