Dumb CSS question

Alexia
Posts: 3001
Joined: Sat 01 Oct, 2005 17.50

Is it possible to have multiple styles in one *.css stylesheet?

If so, how do you differentiate between the two?

If not, how do I instruct the two webpage elements that I want to be styled differently to refer to which stylesheet?
Steve in Pudsey
Posts: 200
Joined: Fri 02 Jan, 2004 09.45

Certainly:


#black{color:#000000}

#white{color:#ffffff}


<.span id="black">This text is black<./span>
<.span id="white">This text is white<./span>
Alexia
Posts: 3001
Joined: Sat 01 Oct, 2005 17.50

So using <.span id> tags instead of div works?
Steve in Pudsey
Posts: 200
Joined: Fri 02 Jan, 2004 09.45

span, div, p, td... any of them would work.
User avatar
WillPS
Posts: 2555
Joined: Tue 22 Apr, 2008 18.32
Location: Carlton
Contact:

To be compliant, you should use classes instead of IDs where you'd repeat use of the same ID.

example:

Code: Select all

.SmallFont{font-size:10px;}
.LargeFont{font-size:15px;}

<span class="SmallFont">This would be at 10px</span>
<span class="LargeFont">This would be at 15px</span>
<span class="SmallFont">This would be at 10px again</span>
The above would function if you chose to use IDs, but wouldn't validate successfully.
Image
Alexia
Posts: 3001
Joined: Sat 01 Oct, 2005 17.50

Thanks for help all. Had to define the CSS parameters in the HEAD of the document in the end. But it works, and it's how I want it to look, finally! Cheers.
Please Respond