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!
Comments
By: Nate (#1)
Using CSS would be much better than 'divs for layout'.
By: exe (#2)
I also think that people should stop calling HTML a "programming language", but that's another topic...
By: Flack (#3)
Only the powerful time will cure these beginners.
By: Jens Wedin (#4)
Proud to use (x)html for structure and css for layout (design). :)
By: jenn.suz.hoy (#5)
The web is still a new enough environment where even the most seasoned designer and developer is learning something new every day (or should be), and those who are experts are a grade or two above the rest, instead of drastic leaps and bounds.
When it comes to web standards for structure and development, we're all still learning best practices. In 5 years, who's to say that CSS won't be passed up for something else that makes our markup cleaner, more precise, and faster to load?
By: Emil Stenström (#6)
By: Ben Millard (#7)
CSS3 selectors should go some way towards reducing the amount of
<div>
s andclass
es present in our markup. There's lots of other CSS developments which will make semantic HTML documents easier to style more efficiently, too.But we'll need some
<div>
s andclass
es in there for several years, until CSS3 selectors gain mainstream support in the browsers most people are using. But there's so many structural elements that you don't need many even now.By: Johan (#8)
Though extra wrapper DIVS are used to make layouts work as intended.
By: Elliot Swan (#9)
I find that sometimes newly converted developers will actually code as though they are using tables, but they just use div tags instead of tr/td tags.
Eventually they'll get it.
By: Jasper (#10)
By: Dustin (#11)
By: Emil Stenström (#12)
@Jasper, Dustin: Thanks! The intention of this site is to try to tell people what I know. Glad to hear some of it is getting through :)
By: Jeff (#13)
By: Emil Stenström (#14)
By: fan-tiger (#15)
By: Dan Edwards (#16)
What MUST be educated to new CSS ers is that it is all to easy to fall into 'divitis' and this is what causes the problems. (divs within divs are almost as bad as nested tables).
DO encourage the use of DIVs - DON'T fall into 'divitis'
By: Emil Stenström (#17)
By: Anders M.J. (#18)
I don't agree with you on using the style function (I presume you mean using the HTML style attribute). It's almost the same as using the font tag: you must edit multiple lines if you want to change something.
I'd make a class instead and call it with the span tag.
By: Mark Stewart (#19)