I’ve been spending some time recently helping people out with their websites and I thought I’d post a few tips on CSS basics.
Let’s cover the difference between ID and Class when we’re talking about CSS.
- IDs should be unique per page.
- IDs are selected with the “#” symbol
- Classes can be shared, multiple elements can have the same class.
- Classes are selected with the “.” (period)
You can combine them and select a class and a specific id.
Use Firebug to help you debug your website on the fly, then transfer the changes to your style.css (or other) stylesheet.
Further (and better) reading:
- The Difference between ID and Class. http://css-tricks.com/818-the-difference-between-id-and-class/
- Selector reference guide: http://css.flepstudio.org/en/css-properties/selector-css.html
- Multiple ID & Class selectors: http://css-tricks.com/5690-multiple-class-id-selectors/