[Note: for those who may be confusing this question with \"why not use tables for HTML layout\", I am not asking that question. The question I\'m asking is why is a grid layout
I believe that CBroe comment is the best option, so I chose to clarify it.
Avoid div
's. A div
should be your last resort, not your first option. Instead, try to use Bootstrap classes on the actual elements. For instance:
<form class="container">
<fieldset class="row">
<label class="span4" for"search">Type your search</label>
<input class="span6" type="text" id="search" />
</fieldset>
</form>
It is a shame to use fieldset to contain a single field, but it is semantically best than using a div
for the same thing. The HTML5 standard defines many new container elements, such as article
, section
, header
, footer
and many more. In some cases you will have to use div
's, but if you minimize it's use then your code will be way more semantic.
if you just use tables i think you will miss out on alot of flexibility in re-sizing your document for mobile/tablets without having to make a separate page for each device. once your table structure is defined all you can really do is zoom in and out.
The difference is that the first example is semantically marked up, assuming the data being marked up is not actually tabular. <table>
should only be used for tabular data, not for any data which happens to be displayed in a layout similar to a table.
It is correct though that using CSS packages like Bootstrap, which require you to assign classes to HTML elements which are not semantic but presentational, reduces the separation of content and presentation, making the difference somewhat moot. You should be assigning semantically meaningful classes to your elements and use lesscss mixins (or similar technology) to assign presentational behavior defined in the CSS framework to these classes, instead of assigning the presentational classes to the elements directly.
Say:
<div class="products">
<div class="product"></div>
</div>
.products {
.row;
}
.products > .product {
.span16;
}
Note that I say should. In practice this is not necessarily always the more workable option, but it should be the theoretical goal.