HTML5 Syntax - HTML 5

What is syntax in HTML5?

HTML 5 has a "custom" HTML syntax which is compatible with both HTML 4 and XHTML1 documents published on the Web, but it is not compatible with more ambiguous SGML features of HTML 4.
HTML 5 does not have same syntax rules as XHTML where lower case tag names are needed. An attribute can have a value for closing all empty elements.
HTML5 has lot of flexibility and would support the following:
  • Uppercase tag names.
  • Quotes are optional for attributes.
  • Attribute values are optional.
  • Closing empty elements are optional.


DOCTYPEs in older versions of HTML are lenghty because the HTML language was SGML based and it requires a reference to a DTD.
Syntax to specify DOCTYPE is shown below:
<!DOCTYPE html>
Above syntax is not case sensitive.

Character Encoding

Syntax to specify Character Encoding is shown below
<meta charset="UTF-8">
Above syntax is not case sensitive.
The <script> tag
It is a easy to add a type attribute with a value of "text/javascript" to script elements as shown below
<script type="text/javascript" src="scriptfile.js"></script>
HTML 5 removes extra information required and user can use below syntax
<script src="scriptfile.js"></script>
The <link> tag
Earlier <link> was written as shown below
<link rel="stylesheet" type="text/css" href="stylefile.css">
HTML 5 removes extra information required and user can use below syntax
<link rel="stylesheet" href="stylefile.css">

HTML5 Elements

HTML5 elements are marked up using start tags and end tags and the tags are delimited using angle brackets along with the tag name in between.
Difference between start tags and end tags is that the end tag includes a slash before the tag name as shown below
HTML5 tag names are not case sensitive and can be written in all uppercase or mixed case. But most common convention is to stick with lower case.
<p>...</p> means the page contains a paragraph and some elements are prohibited from containing any content at all and are known as void elements. Example: br, hr, link and meta etc.
Below is the complete list of HTML5 Elements.




Specifies a comment


Specifies the document type


Specifies an anchor


Specifies an abbreviation


Deprecated:Specifies an acronym


Specifies an address element


Deprecated: Specifies an applet


Specifies an area inside an image map


New Tag: Specifies an independent piece of content of a document, such as a blog entry or newspaper article


New Tag:Specifies a piece of content that is only slightly related to the rest of the page.


New Tag:Specifies an audio file.


Specifies a base URL for all the links in a page


Deprecated: Specifies a base font


Specifies the direction of text display


Specifies the background music


Specifies a text which blinks


Specifies a long quotation


Specifies the body element


Inserts a single line break


Specifies a push button


New Tag:This is used for rendering dynamic bitmap graphics on the fly, such as graphs or games.


Specifies a table caption


Deprecated: Specifies centered text


Specifies attributes for table columns


Specifies groups of table columns


New Tag:Specifies a command the user can invoke.


Puts a comment in the document


New Tag:Together with the a new list attribute for input can be used to make comboboxes


Specifies a definition description


Specifies deleted text


New Tag:Specifies additional information or controls which the user can obtain on demand.


Deprecated: Specifies a directory list


Specifies a section in a document


Specifies a definition list


Specifies a definition term


New Tag:Defines external interactive content or plugin.


Specifies a fieldset


New Tag:Specifies a piece of self-contained flow content, typically referenced as a single unit from the main flow of the document.


Specifies bold text


Deprecated:Specifies big text


Specifies italic text


Specifies small text


Deprecated:Specifies teletype text


Deprecated: Specifies text font, size, and color


New Tag:Specifies a footer for a section and can contain information about the author, copyright information, et cetera.


Specifies a form


Deprecated:Specifies a sub window (a frame)


Deprecated:Specifies a set of frames


Specifies information about the document


New Tag:Specifies a group of introductory or navigational aids.


New Tag:Specifies the header of a section.

<h1> to <h6>

Specifies header 1 to header 6


Specifies a horizontal rule


Specifies an html document


Deprecated: Specifies a single-line input field


Specifies an inline sub window (frame)


Specifies an inline layer


Specifies an image


Specifies an input field


Specifies inserted text


New Tag:Specifies control for key pair generation.


Generate key information in a form


Specifies a labelfor a form control


Specifies a layer


Specifies a title in a fieldset


Specifies a list item


Specifies a resource reference


Specifies an image map


New Tag:Specifies a run of text in one document marked or highlighted for reference purposes, due to its relevance in another context.


Create a scrolling-text marquee


Deprecated: Specifies a menu list


Specifies meta information


New Tag:Specifies a measurement, such as disk usage.


Specifies a multicolumn text flow


New Tag:Specifies a section of the document intended for navigation.


No breaks allowed in the enclosed text


Specifies content to be presented by browsers that do not support the <embed>tag


Deprecated:Specifies a noframe section


Specifies a noscript section


Specifies an embedded object


Specifies an ordered list


Specifies an option group


Specifies an option in a drop-down list


New Tag:Specifies some type of output, such as from a calculation done through scripting.


Specifies a paragraph


Specifies a parameter for an object


Specifies a citation


Specifies computer code text


Specifiesa definition term


Specifies emphasized text


Specifies keyboard text


Specifies sample computer code


Specifies strong text


Specifies a variable


Deprecated: Render the raminder of the document as preformatted plain text


Specifies preformatted text


New Tag:Specifies a completion of a task, such as downloading or when performing a series of expensive operations.


Specifies a short quotation


New Tag:Together with <rt> and <rp> allow for marking up ruby annotations.


Specifies a script


New Tag:Represents a generic document or application section.


Specifies a selectable list


Specifies a white space


Specifies a section in a document


Deprecated: Specifies strikethrough text


Deprecated: Specifies strikethrough text


Specifies a style definition


Specifies subscripted text


Specifies superscripted text


Specifies a table


Specifies a table body


Specifies a table cell


Specifies a text area


Specifies a table footer


Specifies a table header


Specifies a table header


New Tag:Specifies a date and/or time.


Specifies the document title


Specifies a table row


Deprecated: Specifies underlined text


Specifies an unordered list


New Tag:Specifies a video file.


New Tag:Specifies a line break opportunity.


Indicate a potential word break point within a <nobr> section


Deprecated: Specifies preformatted text

HTML5 Attributes

Elements may contain attributes which can be used to set various properties of an element.
Few attributes are defined globally and can be used on any element, whereas others are defined for only specific elements. All attributes have a name and a value. Below is the example of an HTML5 attributes which shows how to mark up a div element with an attribute named class using a value of "example" −
<div class="example">...</div>
Attributes can be specified within start tags and should not be used in end tags.
HTML5 attributes are not case sensitive and can be written in all uppercase or mixed case. But most common convention is to stick with lower case
Here is a complete list of HTML5 Attributes.





User Defined

Specifies a keyboard shortcut to access an element.


right, left, center

Horizontally aligns tags



Places an background image behind an element


numeric, hexidecimal, RGB values

Places a background color behind an element


User Defined

Classifies an element for use with Cascading Style Sheets.


true, false

Specifies if the user can edit the element's content or not.


Menu id

Specifies the context menu for an element.


User Defined

Custom attributes. Authors of a HTML document can define their own attributes. Must start with "data-".


true,false, auto

Specifies whether or not a user is allowed to drag an element.


Numeric Value

Specifies the height of tables, images, or table cells.



Specifies whether element should be visible or not.


User Defined

Names an element for use with Cascading Style Sheets.


List of elements

Used to group elements.


List of items

Used to group items.


true, false

Specifies if the element must have it's spelling or grammar checked.


CSS Style sheet

Specifies an inline style for an element.


User define id

Specifies the element's corresponding item.


Tab number

Specifies the tab order of an element.


User Defined

"Pop-up" title for your elements.


top, middle, bottom

Vertically aligns tags within an HTML element.


Numeric Value

Specifies the width of tables, images, or table cells.

HTML5 Document
Below tags have been introduced in HTML5
  • Section − section tag represents a generic document or application section and can be used combining with h1-h6 for indicating the document structure
  • Article − article tag represents an independent piece of content of a document like a blog entry or newspaper article.
  • Aside − aside tag represents a piece of content which is slightly related to rest of the page.
  • Header − header tag represents the header of a section.
  • Footer − footer tag represents footer for a section and contains author, copyright information, etc.
  • nav − nav tag represents a section of the document which is intended for navigation.
  • Dialog − dailog tag is used to mark up a conversation.
  • Figure − figure tag is used to associate a caption together with some embedded content, like a graphic or video.
  • The markup for an HTMl 5 document is shown below



All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

HTML 5 Topics