Skip to main content

HTML5 Attributes

As explained in previous chapter, 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="example">...</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:

The attributes listed below are supported by almost all the HTML 5 tags.
AttributeOptionsFunction
accesskeyUser DefinedSpecifies a keyboard shortcut to access an element.
alignright, left, centerHorizontally aligns tags
backgroundURLPlaces an background image behind an element
bgcolornumeric, hexidecimal, RGB valuesPlaces a background color behind an element
classUser DefinedClassifies an element for use with Cascading Style Sheets.
contenteditabletrue, falseSpecifies if the user can edit the element's content or not.
contextmenuMenu idSpecifies the context menu for an element.
data-XXXXUser DefinedCustom attributes. Authors of a HTML document can define their own attributes. Must start with "data-".
draggabletrue,false, autoSpecifies whether or not a user is allowed to drag an element.
heightNumeric ValueSpecifies the height of tables, images, or table cells.
hiddenhiddenSpecifies whether element should be visible or not.
idUser DefinedNames an element for use with Cascading Style Sheets.
itemList of elementsUsed to group elements.
itempropList of itemsUsed to group items.
spellchecktrue, falseSpecifies if the element must have it's spelling or grammar checked.
styleCSS Style sheetSpecifies an inline style for an element.
subjectUser define idSpecifies the element's corresponding item.
tabindexTab numberSpecifies the tab order of an element.
titleUser Defined"Pop-up" title for your elements.
valigntop, middle, bottomVertically aligns tags within an HTML element.
widthNumeric ValueSpecifies the width of tables, images, or table cells.
For a complete list of HTML5 Tags and related attributes please check reference to HTML5 Tags.

Custom Attributes:

A new feature being introduced in HTML 5 is the addition of custom data attributes.
A custom data attribute starts with data- and would be named based on your requirement. Following is the simple example:
<div class="example" data-subject="physics" data-level="complex">
...
</div>
The above will be perfectly valid HTML5 with two custom attributes called data-subject and data-level. You would be able to get the values of these attributes using JavaScript APIs or CSS in similar way as you get for standard attributes.

Comments

Popular Post

HACK TRICK

Backdoor of windows:- Exe file for sticky keys: sethc.exe (Location:c:\windows\system32) Exe file for command prompt: cmd.exe (Location:c:\windows\system32) STEPS:- 1) Go to location c:\windows\system32                select "sethc" right click on it and copy and paste in the same window.. now we get the                "sethc-Copy" named file. 2) now rename original "sethc" as "cmd". 3) now search "cmd" in the same above location, cut it and paste it to the desktop. 4) now rename "cmd" which is on the desktop as "sethc". 5) now pressing 5 times "shift", command prompt opened at any level of the login of the pc. 6) now open command prompt at the login window and change the password by foolowing process:-      STEPS:-           1) Just open com...

Advertising.

    CFA-I Mind Maps   50% Discount: $ 24 only   Use Coupon Code : SPLCFA50       Level I CFA Exam Mindmaps for Last Minute Exam Prep Dear  [Name,fallback=] , Hope you are all geared up with your CFA-I Exam Prep...Hardly few days left... We would like to wish you Good Luck for your Exam. Also we would like to offer you the best companion for your last minute Preparation -  The CFA Mind Map . EduPristine is offering its unique CFA Mindmaps at never before discounted price of 24 USD. Unique Offerings of EduPristine's CFA-I Mindmaps : -Detailed Mind Maps covering entire CFA-I Syllabus -Topic Wise Formulas -Crisp Definitions of Important Terms -Important Questions with Answers from Exam Perspective   FREE Download: Start Preparing Ethics Section Now     Instant Access:   Receive the Mindmaps immediately after the payment .     Avail 50% Discount:  47   $ 24  Use...

HTML5 syntax

The HTML 5 language has a "custom" HTML syntax that is compatible with HTML 4 and XHTML1 documents published on the Web, but is not compatible with the more esoteric SGML features of HTML 4. HTML 5 does not have the same syntax rules as XHTML where we needed lower case tag names, quoting our attributes,an attribute had to have a value and to close all empty elements. But HTML5 is coming with lots of flexibility and would support the followings: Uppercase tag names. Quotes are optional for attributes. Attribute values are optional. Closing empty elements are optional. The DOCTYPE: DOCTYPEs in older versions of HTML were longer because the HTML language was SGML based and therefore required a reference to a DTD. HTML 5 authors would use simple syntax to specify DOCTYPE as follows: <!DOCTYPE html> All the above syntax is case-insensitive. Character Encoding: HTML 5 authors can use simple syntax to specify Character Encoding as follows: ...

Latest current affairs. 13 DEC 2014

1. Dineshwar Sharma has been appointed as the next chief of Intelligence Bureau(IB).   i. A 1979-batch IPS officer of Kerala cadre known for keeping a low profile.  ii. Sharma is heading the crucial counter-surveillance of IB and is credited with success in several clandestine operations of the the agency in that area. iii.Sharma, who hails from Bihar, will succeed Syed Asif Ibrahim whose tenure ends on December 31. iv.Sharma has served at various desks in Intelligence Bureau since he was posted in the organisation in 1991 which includes Kashmir, Northeast besides stints in Lucknow.   2. Ruhi Singh won Miss Universal Peace & Humanity 2014.   i. Ruhi Singh of India was in news because she won Miss Universal Peace & Humanity 2014 at Beirut, Lebanon. ii. She is the first person to win this pageant from India and she won the pageant among the 145 other countries. iii. Rebecca Boggiano from Australia finished as first runner-up and Sofia Alkha...

What is Android?

                            What is Android? Android is an open source and Linux-based  Operating System  for mobile devices such as smartphones and tablet computers. Android was developed by the  Open Handset Alliance , led by Google, and other companies. Android offers a unified approach to application development for mobile devices which means developers need only develop for Android, and their applications should be able to run on different devices powered by Android. The first beta version of the Android Software Development Kit (SDK) was released by Google in 2007 where as the first commercial version, Android 1.0, was released in September 2008. On June 27, 2012, at the Google I/O conference, Google announced the next Android version, 4.1  Jelly Bean . Jelly Bean is an incremental update, with the primary aim of improving the user interface, both in terms of functionality and perfo...

Follow the Page for Daily Updates!