{"id":103,"date":"2005-06-15T15:57:20","date_gmt":"2005-06-15T13:57:20","guid":{"rendered":"http:\/\/www.maratz.com\/blog\/archives\/2005\/06\/15\/nested-divs-are-not-evil\/"},"modified":"2008-01-01T10:27:08","modified_gmt":"2008-01-01T08:27:08","slug":"nested-divs-are-not-evil","status":"publish","type":"post","link":"http:\/\/www.maratz.com\/blog\/archives\/2005\/06\/15\/nested-divs-are-not-evil\/","title":{"rendered":"Nested divs are not evil"},"content":{"rendered":"<p>Quite often I run to a discussion about how nowadays developers use nested <code>div<\/code> elements to replace tables. These words mostly come from boring guys who\u2019s only worry is to criticize other people\u2019s work. Well, if you\u2019re one of those, please don\u2019t do that.<!--more--><\/p>\n<h3>Why are tables bad for layout in the first place?<\/h3>\n<p>Apart from being non-semantic, which by itself is nothing to be overly bothered with, the main flaw of using tables for layout is that the content remains within table grid even when unstyled. This restricts comfortable usage in many alternative devices, such as Braille readers and PDAs and that is an accessibility issue. By applying content grid with CSS positioning, we ensure linear flow of the content no matter what.<\/p>\n<h3>On divs<\/h3>\n<p>Used to have a full grid control, designers and developers are often pushed to use nested divisions. From the perspective of orthodox mark-up purists it\u2019s a disaster, but for some people nothing is good enough nor ever will be. For the rest of us who are down here in the trenches and do web sites for a living, there\u2019s a perfectly legible excuse for using nested <code>div<\/code>s when ther\u2019s no other option. The <a href=\"http:\/\/www.w3.org\/\">W3C<\/a> itself <a href=\"http:\/\/www.w3.org\/TR\/2002\/WD-xhtml2-20021218\/mod-text.html#sec_8.6.\">says about divisions<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.w3.org\/TR\/2002\/WD-xhtml2-20021218\/mod-text.html#sec_8.6.\">\n<p>\u201cThe div element, in conjunction with the id and class attributes, offers a generic mechanism for adding extra structure to documents. This element defines no presentational idioms on the content. Thus, authors may use this element in conjunction with style sheets, the xml:lang attribute, etc., to tailor XHTML to their own needs and tastes.\u201d<\/p>\n<\/blockquote>\n<p>Pay attention to <cite>\u201cto tailor XHTML to their own needs and tastes\u201d<\/cite> part. And even though nesting too many <code>div<\/code> elements leads to increased file size, it will render properly in alternative devices and as such is not accessibility threat.<\/p>\n<p>If a broken browser requires a wrapper or two to render web page properly then you should go for it. Remember, users are always in the first place and quasi-purism will not feed your kids.<\/p>\n<h3>Related reading<\/h3>\n<ul>\n<li><a href=\"http:\/\/www.andybudd.com\/archives\/2004\/05\/an_objective_look_at_table_based_vs_css_based_design\/\">An Objective Look at Table Based vs. CSS Based Design<\/a><\/li>\n<li><a href=\"http:\/\/www.sitepoint.com\/print\/exploring-limits-css-layout\">Exploring the Limits of CSS Layout<\/a><\/li>\n<li><a href=\"http:\/\/glazkov.com\/blog\/archive\/2005\/05\/02\/476.aspx\">TILT: How to Stop Feeling Bad About Using Tables for Layout and Start Enjoying Your Markup<\/a><\/li>\n<li><a href=\"http:\/\/www.kingcosmonaut.de\/journal\/3col-layout\/\">3 Column Layouts &#8211; A Different Approach<\/a><\/li>\n<li><a href=\"http:\/\/joshuaink.com\/blog\/196\/a-simple-guide-to-3-column-layouts\">A simple introduction to 3 column layouts<\/a><\/li>\n<li><a href=\"http:\/\/joshuaink.com\/blog\/282\/elastic-fantastic\">Elastic fantastic, or&#8230;<\/a><\/li>\n<li><a href=\"http:\/\/www.alistapart.com\/articles\/flexiblelayouts\/\">Flexible Layouts with CSS Positioning<\/a><\/li>\n<li><a href=\"http:\/\/www.maratz.com\/blog\/archives\/2005\/03\/16\/faux-borders-pseudo-table-effect\/\">Faux Borders and Pseudo Table Effect<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Quite often I run to a discussion about how nowadays developers use nested div elements to replace tables. These words mostly come from boring guys who\u2019s only worry is to criticize other people\u2019s work. Well, if you\u2019re one of those, please don\u2019t do that.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts\/103"}],"collection":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/comments?post=103"}],"version-history":[{"count":0,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts\/103\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/media?parent=103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/categories?post=103"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/tags?post=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}