This is something that makes me crazy every time I see it. Why is using div
elements almost an obsession?
I understand why having mostly div
s in the markup, each one with an id
or (even better) a className
can help develop a clean markup and keep control of visual changes.
But, for example, I keep seeing questions about how to make divs behave like a table, and even when they are told somethings will not be compatible with x or y browser version, they still want to do things like this:
<div style="display: table">
<div style="display: table-row">
<div style="display: table-cell">Content</div>
<div style="display: table-cell">Content</div>
</div>
<div style="display: table-row">
<div style="display: table-cell">Content</div>
<div style="display: table-cell">Content</div>
</div>
</div>
Why? ...really: Why??
Why is that better than using a table
? Or, why is using tables something that abominable?
Tables are part of HTML
elements. They exist for a reason and have a good purpose. They are not deprecated and they are not going to dissapear anytime soon (or sooner than div
s for that matter). And most importantly: they behave correctly in all browsers & versions!
So... why the obession with making div
s behave like tables? Why do so much people write HTML
/CSS
that way and then feel proud of something so dirty?
This is not exclusive to table
s. I keep seeing div
s replacing all html
elements, like h1
..h6
, span
s, etc.
Why??