Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1289 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     HTML/XHTML/DHTML/CSS :

A rather newbie question

Thread title: A rather newbie question
Closed Thread    
    Thread tools Search this thread Display Modes  
11-23-2007, 03:36 PM
#1
Kyrislian is offline Kyrislian
Status: I'm new around here
Join date: Nov 2007
Location:
Expertise:
Software:
 
Posts: 16
iTrader: 0 / 0%
 

Kyrislian is on a distinguished road

  Old  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
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

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
<!--Ryan--> is offline <!--Ryan-->
<!--Ryan-->'s Avatar
Status: Member
Join date: Nov 2007
Location: LakeDistrict, England
Expertise:
Software:
 
Posts: 279
iTrader: 3 / 100%
 

<!--Ryan--> is on a distinguished road

  Old

Originally Posted by Kyrislian View Post
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
Joe is offline Joe
Status: Custom User Title
Join date: Apr 2005
Location:
Expertise:
Software:
 
Posts: 2,297
iTrader: 0 / 0%
 

Joe is on a distinguished road

  Old

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
Kyrislian is offline Kyrislian
Status: I'm new around here
Join date: Nov 2007
Location:
Expertise:
Software:
 
Posts: 16
iTrader: 0 / 0%
 

Kyrislian is on a distinguished road

  Old

Ah! That's cleared up a lot of things. Thanks everyone for taking the time to answer

11-23-2007, 04:56 PM
#6
<!--Ryan--> is offline <!--Ryan-->
<!--Ryan-->'s Avatar
Status: Member
Join date: Nov 2007
Location: LakeDistrict, England
Expertise:
Software:
 
Posts: 279
iTrader: 3 / 100%
 

<!--Ryan--> is on a distinguished road

  Old

No problem. Glad to help.

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed