Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
February 09, 2012, 07:00:59 PM

Pages: [1]   Go Down
  Print  
Author Topic: ID vs Class in CSS Web Design  (Read 1017 times)
Mitch
Berserker Poster
*****
Offline Offline

Posts: 12838


WWW
« on: October 12, 2009, 06:35:39 AM »

Had a very well written tutorial on the differences between ID and Class in CSS web site design via the newsletter I thought I would share with you all here.

Quote
ID vs Class in CSS Web Design

For anybody who has spent any time working with CSS (cascading style sheets), you have to know there is a lot of confusion when it comes to using an id or a class when compiling your web site layout.  Both are selectors, but how should they be used?

So, what I would like to know is how much attention do you usually give to this aspect of CSS?  Did you know it all along, or do you just hack things together until they work?

All in all, no mater which way you work - hope this article comes in handy.
Logged

New to Web Site Hosting? Check Out the Lunarpages Blog Hosting Guide!


Follow us @lunarpages on Twitter!
Important Threads: Read This Before Posting! | Lunarforums Rules! | Mitch's Link of the Day!
Also, be sure to check out and subscribe to the Lunartics Blog and the Lunarpages Newsletter !

Need Web Hosting Help? Check out the Lunarpages Web Hosting Wiki. It has tons of tips, tutorials and resources!
Galen
Space Explorer
***
Offline Offline

Posts: 9


WWW
« Reply #1 on: October 13, 2009, 12:20:26 PM »

I had a hard time keeping them straight at first, but then I made up a silly rule to help me remember:  An ID matches only one person, but there can be many kids in the classroom.  I've always tried to use them properly and not to over "class" things - which is a good thing now that I'm learning that one can do things like:  <div id="apples" class="green">.

Galen
Logged
Mitch
Berserker Poster
*****
Offline Offline

Posts: 12838


WWW
« Reply #2 on: October 13, 2009, 12:23:53 PM »

Very nice, hadn't thought about that - thanks for the tip!
Logged

New to Web Site Hosting? Check Out the Lunarpages Blog Hosting Guide!


Follow us @lunarpages on Twitter!
Important Threads: Read This Before Posting! | Lunarforums Rules! | Mitch's Link of the Day!
Also, be sure to check out and subscribe to the Lunartics Blog and the Lunarpages Newsletter !

Need Web Hosting Help? Check out the Lunarpages Web Hosting Wiki. It has tons of tips, tutorials and resources!
bryanbell
Intergalactic Cowboy
*****
Offline Offline

Posts: 66


WWW
« Reply #3 on: January 30, 2012, 03:05:03 AM »

It is very difficult to decide that when use id and when use class for an element. But simply use id tag when you have to use style once in the document and use class tag when you have to use style at different places in your document. But keep in mind that the id, tag use only once in the document. Once you used this id tag in document you cannot use it again.

For more information check this Video http://www.youtube.com/watch?v=ZpAcK_u_l94
Logged

Pages: [1]   Go Up
  Print  
 
Jump to: