Subscribe to RSS feed!

Don’t use “Divs for layout” please

Proud people all over the world show their new sites and proudly proclaim: “I used divs for layout!”

There’s a problem with the above. Every time someone uses the phrase “Divs for layout” they spread the misconception that divs are some special kind of element. Beginners are tricked into thinking that everything you add to a page should be in a div. I’ve seen great looking pages filled with; you guessed right, only divs.

Some would say that these types of sites actually are worse than table sites. I don’t agree. If you look at it in a wider perspective these people at least are on the right track. They are slowly learning and I as I’ve tried to convey earlier I think it’s ok to start out bad and gradually improve.

So, why is it so bad using only divs? Because the idea of HTML is to convey structure. What structure does your content have? Are some parts more important than others? Are you using lists, but not the list element? Find the tags that best fit your particular purpose. There’s lots of elements out there. Any good front-end web developer should know (almost) all of them.

Now, could we please stop using the phrase “Divs for layout”? If you want an alternative I would say “CSS for layout”. Spread the word my friends!

Friendly Bit is a blog by Emil Stenström, a Swedish web developer that occasionally gets ideas of how to improve the internet.