Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-04-2004, 07:33 PM   PM User | #1
gsnedders
Senior Coder

 
gsnedders's Avatar
 
Join Date: Jan 2004
Posts: 2,340
Thanks: 1
Thanked 7 Times in 7 Posts
gsnedders will become famous soon enough
CSS [when it is an external file]

I have in my HTML document this code
Code:
<p class="bold"
but I want to add a class called "one", so there are two classes, how can I do this?
__________________
Geoffrey Sneddon
gsnedders is offline   Reply With Quote
Old 02-04-2004, 07:39 PM   PM User | #2
mwaw
New to the CF scene

 
Join Date: Feb 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
mwaw is an unknown quantity at this point
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

Last edited by mwaw; 02-04-2004 at 08:24 PM..
mwaw is offline   Reply With Quote
Old 02-04-2004, 07:41 PM   PM User | #3
gsnedders
Senior Coder

 
gsnedders's Avatar
 
Join Date: Jan 2004
Posts: 2,340
Thanks: 1
Thanked 7 Times in 7 Posts
gsnedders will become famous soon enough
Quote:
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.
__________________
Geoffrey Sneddon
gsnedders is offline   Reply With Quote
Old 02-04-2004, 07:56 PM   PM User | #4
Boberto
New Coder

 
Join Date: Nov 2003
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Boberto is an unknown quantity at this point
Do you want 2 classes for the same element?

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

Code:
<div class="one"><p class="bold">Stuff</p></div>
And the css would be something like this:

Code:
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.
__________________
A wise man can see more from the bottom of a well than a fool can see from the top of a mountain.
Boberto is offline   Reply With Quote
Old 02-04-2004, 08:13 PM   PM User | #5
Vladdy
Senior Coder

 
Join Date: Jun 2002
Location: Nashua, NH
Posts: 1,724
Thanks: 0
Thanked 0 Times in 0 Posts
Vladdy is an unknown quantity at this point
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;
}
__________________
Vladdy | KL
"Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"
Vladdy is offline   Reply With Quote
Old 02-04-2004, 08:18 PM   PM User | #6
liorean
The thread killer


 
Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
liorean will become famous soon enoughliorean will become famous soon enough
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'.
__________________
liorean <[lio@wg]>
Articles: RegEx evolt wsabstract , Named Arguments
Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards
liorean is offline   Reply With Quote
Old 02-04-2004, 08:19 PM   PM User | #7
gsnedders
Senior Coder

 
gsnedders's Avatar
 
Join Date: Jan 2004
Posts: 2,340
Thanks: 1
Thanked 7 Times in 7 Posts
gsnedders will become famous soon enough
Having worked out I can do it so all of <p> if affected I only need the one class in the end.
__________________
Geoffrey Sneddon
gsnedders is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:06 PM.


Advertisement
Log in to turn off these ads.