Killersites Community: Class or IDs - Killersites Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Class or IDs

#1 User is offline   youngros 

  • PipPipPipPip
  • View blog
  • Group: Member
  • Posts: 114
  • Joined: 23-December 08
  • LocationMadeira, Portugal

Posted 28 December 2008 - 09:45 AM

When is it best to use them?

I have seen navigation lists with either, but which would be the best in that instance.
0

#2 User is offline   Susie 

  • PipPipPipPip
  • View blog
  • View gallery
  • Group: Advanced Member
  • Posts: 3,359
  • Joined: 19-December 08
  • LocationColumbus, OH

Posted 28 December 2008 - 10:01 AM

I'm sure the others will have differing opinions, but basically, I use IDs for everything that will be unique in my site. For example, I only have one main menu so I'll use an ID for that. For the things that will recur in my site (boxes, styles, etc), I use a class.
0

#3 User is online   Andrea 

  • View blog
  • View gallery
  • Group: Moderators
  • Posts: 5,498
  • Joined: 19-December 08
  • LocationSan Antonio, TX

Posted 28 December 2008 - 10:32 AM

Quote

I'm sure the others will have differing opinions....
It's not a matter of opinion - that is the proper, intended use. IDs for anything that only shows up once, and classes for stuff that's used more than once - on any given page (not site).
0

#4 User is offline   lwsimon 

  • View blog
  • Group: Moderators
  • Posts: 510
  • Joined: 21-December 08
  • LocationHarrison, AR

Posted 28 December 2008 - 11:22 AM

I try to use as few IDs as possible, but use them when necessary.

For instance, I might have a header, a navbar, a content area, and a sidebar on a site. Each of those divs would have an ID, and everything under it would have either a class, or nothing. I would assign another id if I had a discrete content object - like a Coda slider, or something.
0

#5 User is offline   amitte 

  • PipPip
  • View blog
  • Group: New Members
  • Posts: 47
  • Joined: 22-December 08
  • Locationisrael

Posted 28 December 2008 - 11:55 AM

what is a Coda slider?
0

#6 User is offline   Ben 

  • View blog
  • Group: Administrators
  • Posts: 5,409
  • Joined: 19-December 08
  • LocationChico, CA

Posted 28 December 2008 - 12:45 PM

Quote

what is a Coda slider?


It's a javascript effect, made popular by the Coda website. An example of the effect is here: http://www.ndoherty....slider/1.1.1/#1

As most people are saying, I usually organize my code something like this:







The main divs that stay consistent on every page use id's, and anything inside those main divs use classes.
Benjamin Falk | Falken Creative : Twitter : KillerSites Screencast Blog
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter
0

#7 User is offline   LSW 

  • View blog
  • View gallery
  • Group: Moderators
  • Posts: 7,981
  • Joined: 20-December 08
  • LocationJuneau AK

Posted 28 December 2008 - 08:30 PM

You should be using IDs whenever possible. It makes the page more robust and you have control of the elements, two parts of the site may use the same class but it does not work in one or the other so you then need two classes. If the class is in different IDs then it can look slightly different in each. So ID's allow you more flexibility and they can be used with not just CSS but in scripts and programming too. The best sites are those built almost exclusively of IDs. I rarely ever use classes as I can do more with IDs.

IDs may only exist once on a page. Classies can be used often on a page.
Thank You, Migwetth, Gunalche’esh, Ha’w'aa, Danke

Kyle


"90% of user's 'problems' can be resolved by punching them -the other 10% by switching off their PCs."




0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users