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

■ Can India Become A Technology Leader? India

  ■ Can India Become A Technology Leader?   ✅India is presently not a major player in the field of technology due to certain challenges and on the other side, there are many celebrated Indian technologists around the world as many of the technology giants choose an India- born techie as their leader. ✅The conversation around Indian executives at the helm of top tech companies has gathered some momentum with Parag Agrawal taking over as Twitter CEO. The major technology companies like Google and its parent company Alphabet, Microsoft and Twitter, Adobe and IBM are all headed by Indians. ● The Case of the U.S: ✅The Indian immigrants in the U.S are the part of the most educated and professionally accomplished communities in that country. ✅As of 2019, there were 2.7 million Indian immigrants in the U.S. ✅The government of the U.S has been instrumental in the triumphs of enterprise and the free market. ✅The governmental agencies have been actively supporting the research and develo...

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 ...

Free UPSC and Latest Hacking trick.

1. Bibek Debroy joins as full time member of NITI Aayog  i.  Noted economist Bibek Debroy today assumed charged as full time member of the NITI Ayog (National Institution for Transforming India). Government had announced the appointment of Debroy and DRDO chief V K Saraswat as full-time members earlier this month.  ii.  An economist by profession, he was educated at the Presidency College (Calcutta), the Delhi School of Economics and the Trinity College (Cambridge). iii.  Debroy worked as a consultant in the Department of Economic Affairs in Finance Ministry.  iv.  Debroy has also authored several books, papers and popular articles, and has been a Consulting Editor of some financial newspapers in the country.    2. India set to overtake China next year: IMF i. International Monetary Fund (IMF) projected that India will grow 6.5 per cent in 2016, overtaking China which, it projected, will slowdown to 6.3 per cent. ii.  I...

Global Supply Chains... Wuhan Virus

Global Supply Chains 1. The COVID 19 pandemic has disrupted the supply chains and countries are dependent on other countries for items of basic necessities including pharmaceuticals. 2. So, the nations should build supply chains inside the country. Where does it make an impact? 1. China has monopolized the world trade as more than 9 lakh companies are operating in China. So, during the pandemic i. The supply disrupted as manufacturing process stopped in China. ii. This has led to shortage of medicines, manufacturing, Infrastructure etc. across the world. 2. Every country would now move towards the protectionism, atleast in essential commodities like medicines, infrastructure etc. 3. As per WTO, global trade for 2020 will see a downfall ranging from 13% - 32%. 4. IMF has forecasted 3% economic slowdown that will surely jeopardize economic activities of many countries. 5. Idea of realigning towards self-sufficiency would be prioritized by the g...

Follow the Page for Daily Updates!