Before we show examples and discuss the new content tags available to us using HTML5, let's take a look at changes to the syntax of HTML in this new revision. They have removed the need for long references to a DTD in the doctype, and removed the need to specify extra information when establishing connection to external files or when establishing the encoding type of the document. You will notice that all of these now require less information in order to pass as valid HTML5 mark-up.
HTML5 DOCTYPE TAG:
DOCTYPEs in older versions of HTML were longer because the HTML language was SGML based and therefore required a reference to a DTD.
HTML5 use simple syntax to specify DOCTYPE as follows:
HTML5 CHARACTER ENCODING:
HTML5 use simple syntax to specify Character Encoding as follows:
HTML5 <link> TAG:In HTML5 you can use <link> tag simply as following syntax:
<link rel="stylesheet" href="style/style.css">
HTML5 <script> TAG:In HTML5 you can use <script> tag simply as following syntax:
HTML5 elements are marked up using start tags and end tags. Tags are delimited using angle brackets with the tag name in between.
The difference between start tags and end tags is that the latter includes a slash before the tag name.
Following is the example of an HTML5 element:
HTML5 tag names are case insensitive and may be written in all uppercase or mixed case, although the most common convention is to stick with lowercase.
Most of the elements contain some content like <p>...</p> contains a paragraph. Some elements, however, are forbidden from containing any content at all and these are known as void elements. For example, br, hr, link and meta etc.
Find complete list of HTML5 Elements here.
Elements may contain attributes that are used to set various properties of an element.
Some attributes are defined globally and can be used on any element, while others are defined for specific elements only. All attributes have a name and a value and look like as shown below in the example.
Following is the example of an HTML5 attributes which illustrates how to mark up a div element with an attribute named class using a value of "example":
<div class=”classname”> This is a div </div>
Attributes may only be specified within start tags and must never be used in end tags.
HTML5 attributes are case insensitive and may be written in all uppercase or mixed case, although the most common convention is to stick with lowercase.
Find complete list of HTML5 Attributes here.
The following tags have been introduced for better structure:
· section: This tag represents a generic document or application section. It can be used together with h1-h6 to indicate the document structure.
· article: This tag represents an independent piece of content of a document, such as a blog entry or newspaper article.
· aside: This tag represents a piece of content that is only slightly related to the rest of the page.
· header: This tag represents the header of a section.
· footer: This tag represents a footer for a section and can contain information about the author, copyright information, et cetera.
· nav: This tag represents a section of the document intended for navigation.
· dialog: This tag can be used to mark up a conversation.
· figure: This tag can be used to associate a caption together with some embedded content, such as a graphic or video.
The markup for an HTM 5 document would look like the following:
<title>Welcome To HTML5</title>