HTML Attributes

HTML Global Attributes

Global attributes are attributes that can be applied to any HTML element to set common properties.


What Are Global Attributes?

Global attributes are a group of attributes that are valid on every HTML element, regardless of the element's specific purpose. They handle universal concerns like identification, styling, language and interactivity, so you can use the same attribute names consistently across your markup.

Example

Several global attributes on one element
<div id="hero" class="banner" lang="en"
     title="Welcome" data-role="intro" tabindex="0">
  Welcome to MyInternships.in
</div>

Common Global Attributes

AttributeDescription
idA document-unique identifier for the element
classSpace-separated list of class names for CSS and scripting
styleInline CSS declarations applied to the element
titleAdvisory information shown as a tooltip on hover
langLanguage of the element's content, e.g. en, hi, mr
dirText direction: ltr, rtl or auto
hiddenBoolean attribute that hides the element from rendering
tabindexControls keyboard tab order and focusability
contenteditableWhether the element's content can be edited by the user
draggableWhether the element can be dragged (true or false)
data-*Custom author-defined attributes for storing extra data
accesskeyKeyboard shortcut hint to focus or activate the element
spellcheckWhether the browser should check spelling and grammar
💡

Use data-* attributes to attach custom information to elements for JavaScript, e.g. data-job-id="42". Access them in script via the element's dataset property (element.dataset.jobId).

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships