Divs vs. Classes
October 1st, 2008
This may not be an issue anymore, but I remember when I started out I had a hard time wrapping my brain around divs and classes. Looking back now I don’t see why I found it so confusing, because really it isn’t that hard at all. As a matter of fact divs and classes really aren’t related at all. The comparison should be between using IDs and using Classes.
Divs are basically blocks, and they can have an id or a class. Divs are used a lot. When ever you need to apply style to an area of your page, chances are you’re going to use a div.
Now I’ll quickly cover the basic differences between an ID and a class. A class is flexible, and it is something that you can use over and over on a page. If you were listing something, like real estate listings on a single page, and each listing has an image, a headline, some copy, etc. you would probably use a div for each listing, and give it a class, because that class can be repeated and reused on the page. An id though, every id must be unique. IDs can be linked to like anchors.
I know this was just a quick post, just because I wanted to get something up tonight since I just got the site up, but I’m going to come back to this soon with examples. If you have any burning questions, ask away.
This entry was posted on Wednesday, October 1st, 2008 at 8:45 pm and is filed under CSS. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply