caisah
caisah

Reputation: 2087

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>

Upvotes: 4

Views: 955

Answers (2)

Naz
Naz

Reputation: 2775

Using unnecessary divs is not a good idea... if the HTML codes in the second box is enough to do everything that you want or need to do then don't use extra divs... secondly, HTML codes in the second box is much clear and shorter then the codes in the first box... if you keep your codes clean, short and formatted, it will help you a lot when you want or need to update your code in future...

Upvotes: 0

Nick
Nick

Reputation: 6025

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.

Upvotes: 3

Related Questions