Rss Feed Like Us on facebook Google Plus

September 4, 2013

Semantics : HTML5 Features

Semantics is one of the most distinctive features of the Web Platform versus other application platforms. Developers usually ignore or de-prioritize such feature but the mastery of it can bring many benefits to our projects.

The Web is text and text has a meaning. Ultimately the content that our browsers read is pure text. Web sites and web applications have been created in an ecosystem where text based content is linkable, searchable and mashable. In the open web scenario our content can be shown, fed and remixed by third parties, search engines and accessibility tools. All these benefits don't come for free. 

Automated tools can only do half of the job at recognizing the nature of the content. The better job the developer does at marking the right semantics of the content the easier will be for the rest of the agents to deal with it. HTML5 provides a series of tools to make developers life easier too:
  • New media elements.
  • New structural elements.
  • New semantics for internationalization.
  • New link relation types.
  • New attributes.
  • New form types.
  • New microdata syntax for additional semantics.

New Semantic Elements in HTML5

Many of existing web sites today contains HTML code like this: <div id="nav">, <div class="header">, or <div id="footer">, to indicate navigation links, header, and footer.

HTML5 offers new semantic elements to clearly define different parts of a web page:
  • <header>
  • <nav>
  • <section>
  • <article>
  • <aside>
  • <figcaption>
  • <figure>
  • <footer>

HTML5 <section> Element

The <section> element defines a section in a document.
According to W3C,  "A section is a thematic grouping of content, typically with a heading."

  <p>"A Comprehensive technology blog with great articles."</p>

HTML5 <article> Element

The <article> element specifies independent, self-contained content.

"An article should make sense on its own and it should be possible to distribute it independently from the rest of the web site."

Examples of where an <article> element can be used:

  •     Forum post
  •     Blog post
  •     News story
  •     Comment

  <h1>Microsoft Launches Internet Explorer 10</h1>
  <p>Windows Internet Explorer 10 (abbreviated as IE10) was released to
  the  public by Microsoft.....</p>

HTML5 <nav> Element

The <nav> element defines a set of navigation links.

"The <nav> element is intended for large blocks of navigation links. However, not all links in a document should be inside a <nav> element!"

<a href="/html/">HTML</a> |
<a href="/css/">CSS</a> |
<a href="/js/">JavaScript</a> |
<a href="/jquery/">jQuery</a>

HTML5 <aside> Element

"The <aside> element defines some content aside from the content it is placed in (like a sidebar)."

The aside content should be related to the surrounding content.

<p>My family and I visited The Epcot center this summer.</p>
  <h4>Epcot Center</h4>
  <p>The Epcot Center is a theme park in Disney World, Florida.</p>

HTML5 <header> Element

The <header> element specifies a header for a document or section.

"The <header> element should be used as a container for introductory content."

You can have several <header> elements in one document.

The following example defines a header for an article:

    <h1>Internet Explorer 9</h1>
    <p><time pubdate datetime="2011-03-15"></time></p>
  <p>Windows Internet Explorer 9 (abbreviated as IE9) was released to
  the  public on March 14, 2011 at 21:00 PDT.....</p>

HTML5 <footer> Element

The <footer> element specifies a footer for a document or section.

A <footer> element should contain information about its containing element.

"A footer typically contains the author of the document, copyright information, links to terms of use, contact information, etc."

You can have several <footer> elements in one document.

  <p>Posted by: Azziet Singh</p>
  <p><time pubdate datetime="2012-03-01"></time></p>

HTML5 <figure> and <figcaption> Elements

"The <figure> tag specifies self-contained content, like illustrations, diagrams, photos, code listings, etc."

While the content of the <figure> element is related to the main flow, its position is independent of the main flow, and if removed it should not affect the flow of the document.

The <figcaption> tag defines a caption for a <figure> element.

The <figcaption> element can be placed as the first or last child of the <figure> element.

  <img src="img_pulpit.jpg" alt="The Pulpit Rock" width="304" height="228">
  <figcaption>Fig1. - The Pulpit Pock, Norway.</figcaption>

© 2011-2016 Techimpulsion All Rights Reserved.

The content is copyrighted to Tech Impulsion and may not be reproduced on other websites.