HTML5 Attributes

HTML5 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 “banner”:

HTML5 Attributes: Example
<div class=”banner”>…</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.

Standard Attributes:

accesskey
Options: User Defined
Function: Specifies a keyboard shortcut to access an element.

align
Options: right, left, center
Function: Horizontally aligns tags

background
Options: URL
Function: Places an background image behind an element

bgcolor
Options: numeric, hexidecimal,RGB values
Function: Places a background color behind an element

class
Options: User Defined
Function: Classifies an element for use with Cascading Style Sheets.

contenteditable
Options: true, false
Function: Specifies if the user can edit the element’s content or not.

contextmenu
Options: Menu id
Specifies the context menu for an element.

data-XXXX
Options: User Defined
Function: Custom attributes. Authors of a HTML document can define their own attributes. Must start with “data-“.

draggable
Options: true,false, auto
Function: Specifies whether or not a user is allowed to drag an element.

height
Options: Numeric Value
Function: Specifies the height of tables, images, or table cells.

hidden
Options: hidden
Function: Specifies whether element should be visible or not.

id
Options: User Defined
Names an element for use with Cascading Style Sheets.

item
Options: Listof elements
Function: Used to group elements.

itemprop
Options: List of items
Function: Used to group items.

style
Options: CSS Style sheet
Function: Specifies an inline style for an element.

subject
Options: User define id
Function: Specifies the element’s corresponding item.

tabindex
Options: Tab number
Function: Specifies the tab order of an element.

title
Options: User Defined
Function: “Pop-up” title for your elements.

valign
Options: top, middle, bottom
Function: Vertically aligns tags within an HTML element.

width
Options: Numeric Value
Specifies the width of tables, images, or table cells.

spellcheck
Options: true, false
Function: Specifies if the element must have it’s spelling or grammar checked.