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

History of Ladakh

History of Ladakh History of India The standoff at Galwan river raised the question of the significance of Ladakh to India and China. History 1. Ladakh was initially part of Tibetan empire but later broke off in 742 CE after the assassination of King Langdarma. 2. Until the Dogra invasion in 1834, Ladakh was an independent Himalayan state similar to Sikkim and Bhutan. 3. It was integrated into the state of Jammu and Kashmir by the Dogra ruler Gulab Singh. 4. In 1841, Tibet under the Qing dynasty of China tried to invade Ladakh but was defeated by the Sikhs. This led to the Treaty of Chushul by which Tibet agreed to not invade again. 5. After the Anglo-Sikh war in 1845-46, Ladakh was brought under British suzerainty. Significance of Ladakh 1. Ladakh served as an entrepot between Central Asia and Kashmir. Tibetan pashmina shawl was traded through Ladakh to Kashmir. 2. Trade flourished from Karakoram pass to Yarkand and Kashgar to Chinese Turkestan. China’s inte...

Apple is testing a ChatGPT-like AI chatbot

  According to a recent report by Bloomberg's Mark Gurman, Apple is making significant strides in the development of artificial intelligence tools to rival the likes of OpenAI and Google. Internally referred to as "Apple GPT," the tech giant has created a chatbot using its proprietary framework called "Ajax." This framework, built on Google Cloud with Google JAX, enables the creation of large language models similar to ChatGPT and Google's Bard. While Apple is yet to finalize its strategy for consumer release, it is reportedly planning a major AI-related announcement next year. The chatbot's internal rollout faced delays due to security concerns related to generative AI. However, it has been made available to a growing number of Apple employees with special approval, primarily for product prototyping purposes. Apple's chatbot can summarize text and answer questions based on its training data. Although it shares similarities with commercially availabl...

The discovery of Gravitational Waves.

वैज्ञानिकों  ने  अंतरिक्ष  में  गुरूत्वीय  तरंगों  की ऐतिहासिक    की: वैज्ञानिकों ने 11 फरवरी 2016 को घोषणा की कि उन्होंने अंतत: उन गुरूत्वीय तरंगों की खोज कर ली है, जिसकी भविष्यवाणी महान वैज्ञानिक आइंस्टीन ने एक सदी पहले कर दी थी। ब्रह्मांड में जोरदार टक्करों के कारण पैदा होने वाली इन तरंगों की खोज खगोलविदों को इसलिए उत्साहित कर रही है क्योंकि इससे ब्रह्मांड का अवलोकन उसकी क्रमबद्धता में करने का एक नया रास्ता खुल गया है। इस नयी खोज में खगोलविदों ने अत्याधुनिक एवं बेहद संवेदनशील लेजर इंटरफेरोमीटर ग्रेविटेशनल वेव ऑबजर्वेटरी (लीगो) का इस्तेमाल किया, जिसकी लागत 1.1 अरब डॉलर है। लीगो की मदद से उन्होंने दूर दो ब्लैक होल के बीच हुई हालिया टक्कर में पैदा हुई गुरूत्वीय तरंग का पता लगाया। गुरूत्वीय तरंगों की सबसे पहली व्याख्या आंइस्टीन ने वर्ष 1916 में अपने सापेक्षिता के सामान्य सिद्धांत के तहत की थी। ये चौथी विमा दिक्-काल में असाधारण रूप से कमजोर तरंगें हैं। जब बड़े लेकिन सघन पिंड, जैसे ब्लैक होल या न्यूट्रॉन स्टार आपस में टकराते हैं तो उनके गुरूत्...

How to Solve Profit & Loss Questions? Tips & Tricks(SSC CGL)

  How to Solve Profit & Loss        Questions? Tips & Tricks Important Concepts Cost Price  The price at which an article is purchased, is called its cost price. It is abbreviated as  C.P . Selling Price The price, at which an article is sold, is called its selling prices, abbreviated as  S.P. Profit/gain  = SP – CP Profit  % = Profit/(C P)×100 S P  = (100+gain % )/100  ×C P C P  = 100/(100+gain %)×S P Loss If the overall Cost Price exceeds the selling price of the buyer then he is said to have incurred loss . Loss  = C P – S P Loss  % = LOSS/(C P)×100 S P  = (100-loss %)/100×C P C P  = 100/(100-loss %)×S P Profit and Loss Based on Cost Price To find the percent gain or loss, divide the amount gained or lost by the cost.  Example 1 : A toy that cost 80 rupees is sold at a profit of 20 rupees . Find the percent or rate of profit. Answer : Gain / cost...

Follow the Page for Daily Updates!