About Lesson
HTML Global Attributes
HTML global attributes are a set of attributes that can be applied to all HTML elements. They provide additional information about an element’s behavior, style, or content. Let’s explore these attributes in detail:
Attribute | Description |
---|---|
accesskey | This attribute specifies a shortcut key to activate or focus an element. It’s a quick way to navigate to a specific part of your webpage using the keyboard. |
class |
The class attribute specifies one or more class names for an element. These class names refer to a class in a style sheet, allowing you to apply specific styles to elements. |
contenteditable |
This attribute specifies whether the content of an element is editable or not. It can be used to make parts of your webpage editable by the user. |
data-* |
The data-* attribute is used to store custom data private to the page or application. It allows you to store extra information without interfering with the HTML validation. |
dir |
The dir attribute specifies the text direction for the content in an element. It can be used to support right-to-left languages like Arabic or Hebrew. |
draggable |
This attribute specifies whether an element is draggable or not. It can be used to create drag-and-drop functionality. |
hidden |
The hidden attribute specifies that an element is not yet, or is no longer, relevant. It can be used to hide elements from the user. |
id |
The id attribute specifies a unique id for an element. It’s used to identify a single, unique element for scripting or styling purposes. |
lang |
The lang attribute specifies the language of the element’s content. It helps search engines understand the language of your content and can be used by screen readers to change pronunciation rules. |
spellcheck |
This attribute specifies whether the element is to have its spelling and grammar checked or not. It can be used in text fields to help users avoid spelling errors. |
style |
The style attribute specifies an inline CSS style for an element. It’s a way to apply a unique style to a single element. |
tabindex |
The tabindex attribute specifies the tabbing order of an element. It can be used to customize the order in which elements gain focus when the user uses the tab key. |
title |
The title attribute specifies extra information about an element. This information often shows as a tooltip when the user hovers over the element. |
translate |
The translate attribute specifies whether the content of an element should be translated or not. It can be used to prevent automatic translation of specific parts of your webpage. |
These attributes can be used to enhance the functionality, accessibility, and usability of your webpages. Remember, HTML is all about structuring and presenting content on the web, and these global attributes play a crucial role in that process.