i have been trying to establish a firm grip on this css stuff but don't know if i am going about it the right way. is it normal to define like 10 different div classes for a page? should i be nesting so many? if not, what else should i do?If you find yourself defining DIVs that contain only one sub-element, like...
<div id=header>
<h1>The Page Title</h1>
</div>
...you can get rid of the div and instead apply the styling to the element within (in this case the H1). Or even more complex structures, such as UL and OL lists, can have styling applied to the UL/OL element instead of a containing DIV.i have been trying to establish a firm grip on this css stuff but don't know if i am going about it the right way. is it normal to define like 10 different div classes for a page? should i be nesting so many? if not, what else should i do?
Often if you're using a lot of divs it's because you're not using a rich set of HTML tags. When you start to really use semantic HTML you find you have a LOT more styling available through straight element selectors or element selectors grouped in a few divs.Often if you're using a lot of divs it's because you're not using a rich set of HTML tags. When you start to really use semantic HTML you find you have a LOT more styling available through straight element selectors or element selectors grouped in a few divs.
can you elaborate on that for me curly?
i am thinking of all the boxes i make. should all of those be divs or are there other elements i should use? and does it matter if i nest divs?Boxes visually represent something with a special meaning; headers, lists, list items, paragraphs are all block elements. Any one of them can be turned into a "box" by giving them borders, padding, backgrounds and such. Nesting divs or anything else is necessarily bad but it can be a bean counting nightmare keeping track of what goes where. Check out Cederholm's book. Great practical examples.thanks! that helps a lot. i have found so many semantic tutorials but none of them mention anything about the logic of using css.
<div id=header>
<h1>The Page Title</h1>
</div>
...you can get rid of the div and instead apply the styling to the element within (in this case the H1). Or even more complex structures, such as UL and OL lists, can have styling applied to the UL/OL element instead of a containing DIV.i have been trying to establish a firm grip on this css stuff but don't know if i am going about it the right way. is it normal to define like 10 different div classes for a page? should i be nesting so many? if not, what else should i do?
Often if you're using a lot of divs it's because you're not using a rich set of HTML tags. When you start to really use semantic HTML you find you have a LOT more styling available through straight element selectors or element selectors grouped in a few divs.Often if you're using a lot of divs it's because you're not using a rich set of HTML tags. When you start to really use semantic HTML you find you have a LOT more styling available through straight element selectors or element selectors grouped in a few divs.
can you elaborate on that for me curly?
i am thinking of all the boxes i make. should all of those be divs or are there other elements i should use? and does it matter if i nest divs?Boxes visually represent something with a special meaning; headers, lists, list items, paragraphs are all block elements. Any one of them can be turned into a "box" by giving them borders, padding, backgrounds and such. Nesting divs or anything else is necessarily bad but it can be a bean counting nightmare keeping track of what goes where. Check out Cederholm's book. Great practical examples.thanks! that helps a lot. i have found so many semantic tutorials but none of them mention anything about the logic of using css.