Forum Moderators: not2easy
Is it alright to use an empty <div>?
Like so:
<div class="item">some item</div>
<div class="item">some item</div>
<div style="margin-bottom: 1.0em;"></div>
<div class="item">some item</div>
<div class="item">some item</div>
Notice the empty one in the middle. It works fine in Firefox and IE6 but maybe I should be doing something else?
Take care,
Emperor
If, on the other hand, the purpose of the empty <div> is to hold content on some pages, but not on others, or even to serve as a potential place to hook styles onto at a later date, there's nothing wrong with adding it in.
If you haven't already, try taking a look at the html source code used on Dave Shea's CSS Zen Garden [csszengarden.com]. There's a lot of markup provided on that page for the sole purpose of giving designers a "hook" for their style info. Clearly the extra markup doesn't prevent the page from functioning, but, of course, it's used for a very specific purpose that is unique to that site's goals.
cEM
That would be a valid use of an empty div, unless I'm misguided which isn't unheard of.
"If, on the other hand, the purpose of the empty <div> is to hold content on some pages, but not on others, or even to serve as a potential place to hook styles onto at a later date, there's nothing wrong with adding it in."
So adding divs to hold future content is ok. And if you are in a planing stage to start out with, you are most likely going to have divs that you might want to use for something, and change it later. They can be added and removed as content desires.
Isn't css grand! ;)