...

View Full Version : CSS [when it is an external file]



gsnedders
02-04-2004, 08:33 PM
I have in my HTML document this code
<p class="bold" but I want to add a class called "one", so there are two classes, how can I do this?

mwaw
02-04-2004, 08:39 PM
If I'm reading you right, your external stylesheet should include something like this:

.bold {font-size: 14px; font-weight: bold; color: blue;}

.one {font-size: 12px; color: green;}

Of course, change the attributes as-needed.

This is a very basic CSS technique, which leads me to think that you may find a basic CSS tutorial very useful and, in the end, time saving. There are many such tutorials on the web.

Best wishes,

Mike Wilkinson

gsnedders
02-04-2004, 08:41 PM
Originally posted by mwaw
If I'm reading you right, your external stylesheet should include something like this:

.bold {font-size: 14px; font-weight: bold; color: blue;}

.one {font-size: 12px; color: green;}

Of course, chang the attributes as-needed.

This is a very basic CSS technique, which leads me to think that you may find a basic CSS tutorial very useful and, in the end, time saving. There are many such tutorials on the web.

Best wishes,

Mike Wilkinson

i have the lines in the stylesheet, but this does not answer how.

Boberto
02-04-2004, 08:56 PM
Do you want 2 classes for the same element?

If so, then you'll have to do something like this:



<div class="one"><p class="bold">Stuff</p></div>


And the css would be something like this:



div.one p.bold {
color: black;
background-color: white;
}


You can't have 2 classes in one element. You have to use ancestries...I guess. :D

Vladdy
02-04-2004, 09:13 PM
Boberto, RTFM before posting

You can apply as many classes to an element as you want:

<p class="bold red underlined">Some text</p>

where CSS declarations are:

.bold
{ font-weight: bold;
}
.red
{ color: red;
}
.underlined
{ text-decoration: underline;
}

liorean
02-04-2004, 09:18 PM
Wrong. You can have multiple classes in an element, just separate them with a space. <p class='white on black'> is an element with three classes, 'white', 'on', and 'black'.

gsnedders
02-04-2004, 09:19 PM
Having worked out I can do it so all of <p> if affected I only need the one class in the end.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum