Page 1 of 1
Dumb CSS question
Posted: Wed 02 Jan, 2013 19.57
by Alexia
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?
Re: Dumb CSS question
Posted: Wed 02 Jan, 2013 20.12
by Steve in Pudsey
Certainly:
#black{color:#000000}
#white{color:#ffffff}
<.span id="black">This text is black<./span>
<.span id="white">This text is white<./span>
Re: Dumb CSS question
Posted: Wed 02 Jan, 2013 20.13
by Alexia
So using <.span id> tags instead of div works?
Re: Dumb CSS question
Posted: Wed 02 Jan, 2013 20.19
by Steve in Pudsey
span, div, p, td... any of them would work.
Re: Dumb CSS question
Posted: Wed 02 Jan, 2013 20.30
by WillPS
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.
Re: Dumb CSS question
Posted: Wed 02 Jan, 2013 22.44
by Alexia
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.