• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

CSS - Is CLASS or ID better?

SagaLore

Elite Member
A web-designer that I know has suggested that I use IDs, instead of CLASSes, because IDs don't have to look up the Z-order which allows it to load faster. But most information I'm reading based on the W3C standard suggests that I use CLASSes, and not IDs, because there are limitations with IDs.

Which one is better? What are the limitations of each?
 
from what I know:

IDs are required when you need to reference that particular div for things like dhtml layer swapping. Classes can't be referred to in this manner.

I will use classes to assign any styles to a span/div, and if I need to control that div, it gets an ID as well as a class.

z-index is usually automatically determined by nesting order if not specifically stated in your stylesheet.
 
well...

you're using styles to format almost everything on the page, so the site doesn't work in netscape 4.x, which is not so good, especially for a business website.

as useful as I find styles for handling things, i'm a table building sort of guy. the markup is a lot more readable without having to reference two pages to figure out what's being rendered, and it offers better crossbrowser compatibility.

 
Back
Top