HTML5 https://www.digett.com/ en Proper use of HTML5 elements - Semantic Structure https://www.digett.com/insights/proper-use-html5-elements-semantic-structure <span>Proper use of HTML5 elements - Semantic Structure</span> <div class="field field--name-field-teaser-image field--type-image field--label-hidden field__item"> <img src="/sites/default/files/styles/blog_card/public/filefield_images/field_teaser_image/class-header-semantics.jpg?itok=B-okMNLL" width="495" height="370" alt="" typeof="foaf:Image" /> </div> <span><span lang="" about="/users/art-williams" typeof="schema:Person" property="schema:name" datatype="">Art Williams</span></span> <span>Wed, 10/26/2011 - 8:24am</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>When web developers moved from table-based to non-table-based layouts, the syntax change was relatively simple: use a &lt;div&gt; element instead of &lt;table&gt;, &lt;tr&gt;, or &lt;td&gt;. The hard part was learning how to use position, float, and clear in your css to make it all look right.</p> <!--break--><p>With the transition to HTML5 the problem seems to be reversed. HTML5 doesn’t make any changes to the process of laying out a site — we still use position, float, and clear to align elements. However, there 30+ new elements in HTML5. Some are used for media (such as &lt;audio&gt; and &lt;video&gt;) and others for forms, but most of them are used for document structure. The mistake most developers seem to be making, myself included, is seeing these new elements as either extensions or replacements of the &lt;div&gt; elements. Both of those views are wrong.</p> <h2>Document Outline</h2> <p>HTML5 elements were created to help us better explain the semantic structure of the content in an HTML document. They will have the greatest influence over what is called the Document Outline. The Document Outline in previous versions of HTML was largely an outline of the heading elements (h1, h2, etc), but HTML5 has given us 20 or so new elements just for defining regions of a document.</p> <p>Some of these new elements are self-explanatory, such as &lt;header&gt;, &lt;footer&gt;, and &lt;nav&gt;, but other can be a little tricky to understand. And since the &lt;div&gt; element has no real impact on the document outline, we have grown accustomed to viewing it as a purely layout-based element. For example, we wrap it around some content so that we can style and place that content where we want. It is a little bit of a struggle to keep the layout aspect of the element as secondary when dealing with these new HTML5 elements.</p> <p>That doesn’t mean that you can’t float a &lt;header&gt;; by all means, go ahead, but that’s not the reason you place a &lt;header&gt; element around the header of the document. Document Outline is the primary concern with HTML5 elements and layout attributes are added to the elements because they are already there. If you have something you need to style that doesn’t belong in the Document Outline, then put a &lt;div&gt; around it and go to town theming it.</p> <h2>Section Element</h2> <p>The most commonly misused HTML5 element is probably the &lt;section&gt;. It is common to see it replace the outer &lt;div&gt; of various areas on a site. This misuse of &lt;section&gt; can make the Document Outline of your html unintelligible.</p> <p>A &lt;section&gt; is any grouping of content that is different than other groupings of content on that page. W3C uses the example of a chapter in a book as a section. A &lt;section&gt; may declare a group of &lt;articles&gt; (blog posts for example). A section can also declare a side block that contains a list of recent comments on the site that aren’t necessarily related to the article in the main content area. Another great use for the &lt;section&gt; element is when you want to create a site that what would normally be multiple pages of content on one long page using javascript to open and collapse the areas as you navigate. Any place where you are using tabs of content is also likely a great candidate for the &lt;section&gt; element.</p> <h2>SEO Effect</h2> <p>In those last two examples, where you are using some kind of javascript to hide or display content as the user clicks on your navigation, you would usually have to make a trade-off on the SEO side of things in order to build that kind of nice effect. But the &lt;section&gt; element comes to the rescue.</p> <p>After declaring the start of a new section you are free to start over with nearly all of your page elements, h1, h2, header, footer, etc. This is a boon for SEOs who would typically have insisted that each of those “tabs” be their own page for the keyword benefits. With HTML5 you can now target unique and specific keywords in each &lt;section&gt; of the html document.</p> <p>In the end HTML5 will make it easier for the content on a webpage to be more specifically declared. The more we separate the theming layer from the Document Outline the easier it will be for other computers to understand the data. In the short term this means search engines can index content more accurately, and in the long run website data can be integrated into other devices and sites more easily.</p> <p>My recommendation is that we, developers, start developing using HTML5 markup if we haven’t already. It will take a little time to grasp all the nuance, but as with the change away from tables it will be for the best. If you are a Drupal front-end developer, you might want to start with one of the <a href="/blog/06/29/2011/html5-base-starter-themes-drupal-7">HTML5 starter themes</a>. If not, then I’m a fan of the <a href="http://html5boilerplate.com/">HTML5 boilerplate</a>, which one of our developers, Alex, used to build <a href="/san-antonio-web-design/">San Antonio Web Design</a>.</p> <p>Image: <a href="http://www.w3.org/">W3C</a></p> <h2>Related Articles</h2> <ul> <li><a href="/blog/06/29/2011/html5-base-starter-themes-drupal-7">HTML5 Base Starter Themes in Drupal 7</a></li> <li><a href="/blog/09/29/2011/san-antonio-web-design">San Antonio Web Design</a></li> <li><a href="/blog/04/08/2011/mobile-website-design-best-practices-good">Mobile Website Design Best Practices: The Good</a></li> </ul> </div> <section> <h2>LEAVE A COMMENT</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=775&amp;2=comment_no_subject&amp;3=comment_no_subject" token="QehSCUXHOo7lQ7G6J2pML1z2fQCwE72_rRnBBMAf3ww"></drupal-render-placeholder> </section> <div class="sharethis-wrapper"><span st_url="https://www.digett.com/insights/proper-use-html5-elements-semantic-structure" st_title="Proper use of HTML5 elements - Semantic Structure" class="st_facebook_large" displayText="facebook"></span> <span st_url="https://www.digett.com/insights/proper-use-html5-elements-semantic-structure" st_title="Proper use of HTML5 elements - Semantic Structure" class="st_linkedin_large" displayText="linkedin"></span> <span st_url="https://www.digett.com/insights/proper-use-html5-elements-semantic-structure" st_title="Proper use of HTML5 elements - Semantic Structure" class="st_twitter_large" displayText="twitter"></span> <span st_url="https://www.digett.com/insights/proper-use-html5-elements-semantic-structure" st_title="Proper use of HTML5 elements - Semantic Structure" class="st_email_large" displayText="email"></span> </div> Wed, 26 Oct 2011 13:24:33 +0000 Art Williams 775 at https://www.digett.com