- Home
- /
- HTML Global Attributes
HTML Tutorial
INTRODUCTION
HTML BASIC TAGS
INLINE & BLOCK ELEMENTS
HTML LISTS
HTML TABLES
HTML FORMS
HEAD ELEMENTS
HTML MEDIA
MISCELLANEOUS TAGS
- Home
- /
- HTML Global Attributes
HTML Global Attributes
Global attributes are special attributes that can be applied to any HTML element. They help developers add behavior, style and custom metadata across element uniformly.
What are Global Attributes?
Global attributes are universal– they work on all standard HTML elements. These attributes make HTML more flexible, especially when combined with CSS and JavaScript.
Common Global Attributes
Attribute | Description |
---|---|
class | Defines one or more CSS class names for the element |
id | Assigns a unique identifier to the element |
style | Applies inline CSS styles |
title | Adds a tooltip (shows on mouse hover) |
accesskey | Specifies a keyboard shortcut to activate the element |
contenteditable | Allows the element’s content to be editable |
hidden | Hides the element from the page |
lang | Declares the language of the element’s content |
tabindex | Specifies the element’s tab order |
draggable | Indicates whether the element is draggable or not |
data-* | Used to store custom data (data-user , data-role , etc.) |
Usage Examples
class
Attribute
This is a container.
Applies CSS styling via a class
id
Attribute
Unique Element
Used for JavaScript targeting or CSS styling of a single element.
data-*
Attribute
Custom Data
Stores custom data accessible via JavaScript (dataset. user
).
contenteditable
Attribute
You can edit this text!
Allows users to edit the text directly in the browser.
Why Use Global Attribute
- Reusability across all HTML elements
- Easier styling and class management
- Enable interactivity and custom behavior
- Adds semantic meaning or metadata
Conclusion
HTML Global Attributes are your toolkit for customization across all HTML elements. Mastering them allows for more dynamic, accessible, and manageable HTML structures- especially useful when integration with CSS and JavaScript.