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

Most Important Topics. International , Science , UPSC, BPSC..

  International Relations Prev First in-Person Meeting of Quad Countries           Star marking (1-5) indicates the importance of topic for CSE Tags:  GS Paper - 2 Groupings & Agreements Involving India and/or Affecting India's Interests Why in News Recently, the first in-person meeting of  Quad  leaders was hosted by the US. Issues like climate change, Covid-19 pandemic and challenges in the Indo Pacific, amidst China's growing military presence in the strategic region, were discussed in the meeting. Key Points Background: In  November 2017, India, Japan, the US and Australia gave shape to the long-pending proposal of setting up the Quad  to develop a new strategy to keep the critical sea routes in the Indo-Pacific free of any influence. China claims nearly all of the disputed  South China Sea , though Taiwan, the Philippines, Brunei, Malaysia and Vietnam all claim parts of it. The South China Sea is an arm of the Western ...

Oil report

The United Nations (UN) on 18 December 2014 sent a team of international experts to help Bangladesh in cleaning up the Sundarbans oil spill. The team belonging to the United Nations Disaster Assessment and Coordination (UNDAC) was sent on a request from Bangladesh government. The UN team will help Bangladesh government in the ground work and will also conduct an assessment and advise on recovery and risk reduction measures. The team comprises of experts from Britain, European Union, France and the United States. Besides, the UN asked Dhaka to impose a complete ban on the movement of commercial vessels through the Sundarbans.

World most famous article

1. Walmart to open new store in India after 2-year gap  i. After a gap of two years, US retail major Walmart will open a new cash and carry store in Agra as it returns focus on India.  ii. The company, which opened its last store in Bhopal towards the end of 2012, has said it will focus on cash and carry business in India in the absence of clarity on FDI in multi-brand retail trade. iii. "Walmart is committed to India and we are focused on our growth plans... We have recently received all internal approvals for opening a new store in Agra, our second one in the city," Walmart spokesperson told PTI. 2. Jyotsna Suri elected as the President of the FICCI i. Jyotsna Suri, Chairperson of Bharat Hotels, on 20 December 2014 was elected as the President of the Federation of Indian Chambers of Commerce & Industry (FICCI). ii. Suri succeeded Sidharth Birla. iii. Alok B Shriram, deputy managing director of DCM Shriram Industries Ltd, assumed the charge of the presid...
1. Suicide bomb, gunfight at Afghan bank, civilians inside. i. Taliban militants detonated a suicide bomb and stormed a bank in southern Afghanistan . ii. The attackers forced their way inside after the bomb exploded at the entrance of the Kabul Bank branch in Lashkar Gah killing at least six people, the capital of the insurgency-racked province of Helmand. iii. A Taliban spokesman claimed responsibility for the attack on Kabul Bank, an institution that nearly collapsed in 2010 in a $900 million fraud case that underlined endemic corruption in Afghanistan.  2. Lok Sabha passed NCT of Delhi Laws (Special Provisions) Amendment Bill, 2014. i. The Lok Sabha passed the National Capital Territory (NCT) of Delhi Laws (Special Provisions) Amendment Bill, 2014. The bill was presented in Lok Sabha by the Union Urban Development Minister Venkaiah Naidu. ii. The Bill seeks to amend the National Capital Territory of Delhi Laws (Special Provisions) Second Act, 2011 as the deadlines...

GDP projection by IMF:

 GDP projection by IMF:   ðŸ‡¨ðŸ‡³ China GDP: 2023: $19.374 trillion 2028: $27.4 trillion 2075: $57 trillion 🇮🇳 India GDP: 2023: $3.737 trillion 2028: $5.5 trillion 2075: $52.5 trillion 🇺🇲 US GDP: 2023: $26.855 trillion 2028: $32.3 trillion 2075: $51.5 trillion

Follow the Page for Daily Updates!