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

India & Russia Relation

1.  India expects Russia to be more involved in the Indo-Pacific and to look to its own interests in the region. 2. This will create a mutual basis for cooperation and dialogue. 3. Investments in Vietnam’s oil and gas sector is seen as one of the areas of cooperation as both India and Russia have planned to invest in this sector. 4. India also sees Russia as a very important Pacific power 5. Russia has an interest in the Indian Ocean and India has an interest in the Pacific Ocean. 6. As, Indo-Pacific is seen as a geographic continuum for cooperation and for certain principles, India wants Indo-Pacific region to be free and fair for everyone. 7. Russia views its engagement would create new divisions especially with respect to containment of China. 8. On the other hand, India neither views it as containment nor non-containment but as a positive construct that brings together countries on the basis of certain principles. South China sea 1. A stable Indo-Pacific assumes particular impo...

SSC WORD

1. TRANQUILITY : शांति Meaning:  a peaceful, calm state, without noise, violence, worry, etc. Synonyms:  calmness, coolness Antonyms:  chaos, loudness Example:  Not surprisingly, the desire for tranquility among local inhabitants is almost palpable. 2. REBOUND : वापस आना Meaning:  If an action rebounds on you, it does not have the effect you hoped for but has an unpleasant effect on you instead Synonyms:  recoil, recuperate Antonyms:  weaken, hurt Example:  His continual demands for sympathy rebounded on him because his friends finally stopped listening. 3. INVIGORATE : प्रोत्साहन Meaning:  to give new energy or strength to someone or something Synonyms:  boost, stimulate Antonyms:  discourage, dissuade Example:  They argued that a cut in the tax rate would invigorate the ec...

UPSC

&#128204;PERIOD POVERTY Scotland may become the first country in the world to end ‘period poverty’ by making sanitary products free for all. About: • The Scottish Parliament passed the Period Products (Free Provision) (Scotland) Bill. • Referring to “period dignity”, the legislation aims to develop a universal system in Scotland, which will provide free sanitary products for “anyone who needs them”. • As of now, in Scotland, the provision of free sanitary products is already available in schools, universities and colleges. • The Bill has only passed the first hurdle to become a law. It still needs to be considered by a parliamentary committee, following which it will require approval from the parliament. It will finally need the Royal Assent of the Queen.  ▪️Important Info : What is ‘period poverty’? Some circumstances make menstruation a “difficult experience” for women. T...

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

जम्मू और कश्मीर में सुरंगें Tunnels in Jammu & Kashmir

जम्मू और कश्मीर में सुरंगें Tunnels in Jammu & Kashmir केंद्रीय सड़क परिवहन और राजमार्ग मंत्री विभिन्न राष्ट्रीय राजमार्ग (National Highway- NH) परियोजनाओं की आधारशिला रखेंगे तथा केंद्रशासित प्रदेश जम्मू एवं कश्मीर में जेड-मोड़  (Z-Morh)  तथा जोजिला सुरंग ( Zojila Tunnel)  की समीक्षा एवं निरीक्षण करेंगे। प्रमुख बिंदु श्यामा प्रसाद मुखर्जी सुरंग:  चेनानी-नाशरी सुरंग (Chenani-Nashri Tunnel) का नाम बदलकर श्यामा प्रसाद मुखर्जी सुरंग (Shyama Prasad Mukherjee Tunnel) कर दिया गया है। यह न केवल भारत की सबसे लंबी राजमार्ग सुरंग (9 किमी. लंबी) है बल्कि एशिया की सबसे लंबी द्वि-दिशात्मक राजमार्ग सुरंग (Bi-directional Highway Tunnel) भी है।  यह जम्मू एवं कश्मीर में उधमपुर तथा रामबन के मध्य निम्न हिमालय पर्वत शृंखला में स्थित है। बनिहाल काज़ीगुंड सुरंग:  यह बनिहाल और काज़ीगुंड को जोड़ने वाले जम्मू एवं कश्मीर केंद्रशासित प्रदेश में पीर पंजाल रेंज में 1,790 मीटर की ऊंँचाई पर स्थित 8.5 किमी. लंबी सड़क सुरंग (Road Tunnel) है। जवाहर सुरंग:  इसे बनिहाल सुरंग (Banihal Tu...

Follow the Page for Daily Updates!