|
|
|
|
Thread title: A rather newbie question |
|
|
|
|
|
Thread tools
Search this thread
Display Modes
|
|
11-23-2007, 03:36 PM
|
#1
|
Status: I'm new around here
Join date: Nov 2007
Location:
Expertise:
Software:
Posts: 16
|
A rather newbie question
I've been playing around with CSS for quite a long time now, but that was just a lot of messing around. Now, I gotta face the light *shame-faced*
How, exactly, do you determine when to use .class or #id?
And on a lesser note, <div> and <span>?
This newb will really appreciate the explainations
|
|
11-23-2007, 03:53 PM
|
#2
|
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
Posts: 5,200
|
You use .class when you have something like this:
Code:
<a href="#" class="class">link</a>
You would use .class to select that using CSS. For #id's you would select those by using:
Code:
<a href="#" id="id">link</a>
A div is used to collectively wrap around several elements where needed. Good examples are sidebars, wrappers, and sometimes footers. Don't overuse them though. As for spans, you should really only use those when you have to style text inside a p tag (or other tag) differently than the rest of the text in that tag.
|
|
11-23-2007, 03:57 PM
|
#3
|
Status: Member
Join date: Nov 2007
Location: LakeDistrict, England
Expertise:
Software:
Posts: 279
|
Originally Posted by Kyrislian
I've been playing around with CSS for quite a long time now, but that was just a lot of messing around. Now, I gotta face the light *shame-faced*
How, exactly, do you determine when to use .class or #id?
And on a lesser note, <div> and <span>?
This newb will really appreciate the explainations
|
Ok first off <div> is a division and is mainly used to dived areas of a page in to sections. Most people use this to group elements together.
span is used for another style handle when there is nothing left to use. You can add spans on most elements but not all.
Ok the diffrence between .class and #id is that #id's can only be used once on a page so they are unique. Classes can be used over and over again.
I hope this helps you.
|
|
11-23-2007, 04:32 PM
|
#4
|
Status: Custom User Title
Join date: Apr 2005
Location:
Expertise:
Software:
Posts: 2,297
|
Mainly, you would use classes to simply, classify elements, say if you have a bunch of links, and you want to give some of them a certian look, you would give them a class.
For IDs, they have to be on unique elements, usually block elements or to identify form fields. A good example would be applying an ID to an anchor tag so you can skip to that part of the page, or to identify main areas of a page, such as your content section, footer, etc.
Divs are mainly used on web pages to divide the page up into logical sections. For example, you would have one div tag for the header of a page, one for the footer, etc.
Spans are plain elements, which apply no formatting to the content you put inside them. They're popular because of this and allow you to specify certain styles in your CSS document knowing that if the user doesn't have CSS enabled, then these styles won't get rendered unlike using a strong or bold tag which would then render your content as bold even if you canceled that property out in your CSS document if the user has disabled or used his own CSS document.
|
|
11-23-2007, 04:41 PM
|
#5
|
Status: I'm new around here
Join date: Nov 2007
Location:
Expertise:
Software:
Posts: 16
|
Ah! That's cleared up a lot of things. Thanks everyone for taking the time to answer
|
|
11-23-2007, 04:56 PM
|
#6
|
Status: Member
Join date: Nov 2007
Location: LakeDistrict, England
Expertise:
Software:
Posts: 279
|
No problem. Glad to help.
|
|
|
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|