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

UPSC MCQ

Consider the following statements: 1. Polavaram Project is a multi-purpose irrigation project. 2. It is a dam located across Krishna River. 3. The dam is located in Telangana state. Which of the above written statements is/are true? Choose the correct code from the options given below: A. 1 only B. 3 only C. 1 and 2 D. 2 and 3 Explanation : Polavaram Project is a dam located across Godavari River, located in Andhra Pradesh. It was accorded national project status as part of the legislation bifurcating Andhra Pradesh in 2014. Recently, the Ministry of Water Resources (MoWR), National Water Development Agency (NWDA) and National Bank for Agriculture and Rural Development (NABARD) signed a fresh Memorandum of Agreement (MOA) to provide for a total Rs 1,400 crore as part of the central share. Which of the following statements regarding military exercises is/are correct? 1. Coordinated Patrol (CORPAT) is bilateral naval exercise held between India and Indonesia. 2. Rim of ...

code project , How to learn app development,website ,etc

Welcome to the CodeProject Daily Build Read online version     Wednesday, July 15, 2020 UnoConf 2020 – Virtual & Free Uno Platform’s one day, single-track free online conference on WinUI and Uno Platform powered cross-platform application development for Desktop, Web and Mobile with C# and XAML. Speakers from Microsoft and Uno Platform’s open-source team.  Register now. Headline article Introduction to ELENA Programming Language   (57 votes) by Alex Rakov, Alexandre Bencz (updated  19 hours ago) ELENA is a general-purpose, object-oriented, polymorphic language with late binding New Articles, Tech Blogs and Tips Applications & Tools Tip about importing old fashioned JavaScript libraries into ES6 / ES11 project with webpack   (0 votes) by Sem Shekhovtsov (updated  yesterday) Importing jQuery UI library into ES6 project Artificial Intelligence and Machine Learning Face Touch Detection with TensorFlow.js Part...

So Far Away from the Martin Garrix. Song of the Day.

&#128304;SONG OF THE DAY&#128304; &#128304;&#127932; So Far Away from The Martin Garrix Collection: Deluxe Edition &#127908; by Martin Garrix feat. David Guetta, Jamie Scott & Romy Dya&#128304; Light 'em up, light 'em up Tell me where you are, tell me where you are Summer nights, bright lights And the shooting stars, they break my heart Calling you now, but you're not picking up Shadow's so close if you are still in love Then light a match, light a match Baby, in the dark, show me where you are Oh, love How I miss you every single day when I see you on those streets Oh, love Tell me there's a river I can swim that will bring you back to me 'Cause I don't know how to love someone else I don't know how to forget your face No, love God, I miss you every single day, and now you're so far away So far away It's breaking me, I'm losing you We were far from perfect, but we were worth it Too many fight...

Indian Air Force Wing Commander Abhinandan Varthaman

Indian Air Force Wing Commander Abhinandan Varthaman has been chosen for the first Bhagwan Mahavir Ahimsa Puraskar constituted by the Akhil Bharatiya Digambar Jain Mahasamiti. The award which carries a cash prize of Rs. 2.51 lakh, a memento and a citation will be presented to  Abhinandan Varthaman on April 17 the Mahavir Jayanti.

Follow the Page for Daily Updates!