DIV ID vs DIV CLASS
- Started
- Last post
- 12 Responses
- jaylarson0
Currently my site is designed with DIV IDs (about 10 that show on each with different content). Since I am unable to give a link yet, would you all recommend converting to classes instead?
- jaylarson0
thanks everybody. I also use DIV IDs for structuring and CLASS for repeated elements.
I guess what I was being ambivelent about is that I am having FF/IE problems. I have a #container (#top, #leftnav, #content, #header [bad placement I will change], ... #footer), when adjusting #content from 535px wide to 540 px wide, it jumps down underneath #leftnav.
I am confused.
Here is a link to the css:
http://www.writersblood.com/onpo…Anyhelp would be just dandy, even if it is to tell me that my stylesheet is all wrong (as long as you tell me how to fix it!)
peace peace peace
j
- asprin0
General rule is IDs are unique and can only be used once on a page while classes can be applied to any tag ie:
etc.
I used IDs for the basic structre of the page... header, nav, content area, parent container, footer etc.
- jakeyj0
your content going below your nav is perfectly normal. Your #content DIV is to big so it moves down below the left nav.
remember the box model
also, its a good idea to specify your text size in ems.
- jaylarson0
Dear NT,
Here is the link.
http://www.writersblood.com/gree…Is the difference between FF and IE because of the Box Model problems? If so, please let me know how to fix it.
Thanks!!!
j
- jaylarson0
EMs for text. I heard there were problems with browers rendering them. Or am I just outta the loop?
- heavyt0
no problems with EMs.
- jakeyj0
yes it is probably because of the box model.
you can fix it using a hack, but try not to if possible. you'll be better off.
- heavyt0
also,
although I am not lookign at it on a oc, i see that you are using padding (left and right) and also settign an explicit width.
This is where the box model breaks design.
you will need to look out for padding (and borders) and write a BMH for them
- jaylarson0
thanks everybody so far.
- monNom0
id is for styling one element, and can be referenced by javascript.
class is for styling multiple elements.
- jakeyj0
monNom is right
take it easy on the classes. you can easy bury yourself if your not careful.