...

View Full Version : Basic Css Help



ClickList
09-20-2006, 10:51 PM
Hello friends

I have 2 questions regarding the same problem. Are basic questions what I can test myself, but I wish know if in the specifications how it is resolved and if the browsers follow correctly.

(1) Imagine what I have my file called styles.css. I have these style:

.test { font-family: verdana; }
.test { color: blue; }

in the html document, I have
<div class="test">My sample text</div>

"My sample text" will render formatted with "Verdana" font and "Blue" color?

(2) Now in the styles.css . I have these style:

.test { color: red; }
.test { color: blue; }

"My sample text" will render formatted with red or blue color?

Regards

mark87
09-20-2006, 10:55 PM
There's no attribute font-color, I assume you meant color. It'd take the last value given (blue).

ClickList
09-21-2006, 12:27 AM
There's no attribute font-color, I assume you meant color. It'd take the last value given (blue).

Thank you, do you talked about the item (2). And (1)?

mark87
09-21-2006, 12:46 AM
In example 1, yes it would be blue and have a font-family of Verdana; in example 2, it would be blue.

You don't need to specify the element twice though, .test { font-family: Verdana; color: #00F } would work fine.

Graft-Creative
09-21-2006, 12:55 AM
.test { color: red; }
.test { color: blue; }



You can't have the same class with different attributes, well, you can, but the last one would simply cancel out the first, thus rendering the first style redundant - fine (if pointless) if using inline styles, but not if linking to an external stylsheet.

Better to use two different classes, and name them in a contextual way i.e.



.highlight { color: red; }
.lowlight { color: blue; }


Kind regards,

Gary

ClickList
09-21-2006, 01:52 AM
Thank you, I understood.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum