Search code examples
htmlsemantics

Is it a bad practice to use divs for styling purposes?


I've seen lately a lot of discussions about this new concept called oocss and I was wondering if it is a bad practice to wrap your main tags in divs only for styling/page layout purposes.

I'm asking this because I see some frameworks like Twitter Bootstrap use such a method.

What are the implications of such a markup from a semantic and accessibility point of view?

For example:

<div class="container">
  <div class="row">
    <div class="span4">
      <nav class="nav">...</nav>
    </div>
    <div class="span8">
      <a href="#" class="btn btn-large">...</a>
    </div>
  </div>
</div>

instead of

<div class="menu">
  <nav class="nav">...</nav>
  <a href="#" class="bttn">...</a>
</div>

Solution

  • No, it's fine. HTML is a "mark-up language", and mark-up involves styling. Besides, everyone does it. Many of the fluid multi-column layouts rest precisely on this approach.