PDA

View Full Version : Applying style.css styles to text?????



888
15 Jul 2008, 06:38 AM
I already have a style.css with defined selectors and declarations such as
#text font: Georgia etc.

and

#body font: Times New Roman.



Now if I have text under the body category, i.e. all the text in the page, what do I have to do apart from manually using <div> codes via the coding page in dreamweaver to apply say #text to the text in question?

I.E. how to make a css style a class from say #text in style.css?

So how do I apply #text to selected text on the page?

kudos
15 Jul 2008, 08:09 AM
Firstly in your stylesheet the body does not need the #.

# is used to select an element as an ID. IDs can only be used once on any given page.
eg. <div id="main-content">BLAH BLAH</div>
Would be selected by

#main-content {} in your CSS.

For the body, you just use:

body {font-family:whatever;}

then if you want a different font in a particular div, you specify that div only in the div using the ID method above.

If you want to use similar styles repeatedly on a page, you would use a class. Classes are selected with a . in the css.

<div class="blue-text">This text is blue</div>

In your CSS would be:

.blue-text {color:blue;}