HTML global attributes are attributes that can be used with any HTML element. These attributes provide common functionalities and behaviors across different elements. Here are some commonly used HTML global attributes:
1. `class`: Specifies one or more class names for an element. Used for styling and selecting elements with CSS or JavaScript.
Example: `<div class="container">`
2. `id`: Specifies a unique identifier for an element. Used for styling, JavaScript targeting, or linking to specific elements within a page.
Example: `<h1 id="main-heading">`
3. `style`: Defines inline CSS styles for an element.
Example: `<p style="color: blue;">`
4. `title`: Provides additional information or a tooltip text about an element when the user hovers over it.
Example: `<a href="#" title="Click here for more information">`
5. `lang`: Specifies the language of the element's content.
Example: `<html lang="en">`
6. `dir`: Specifies the directionality of the element's content, such as left-to-right (`ltr`) or right-to-left (`rtl`).
Example: `<div dir="rtl">`
7. `data-*`: Allows you to store custom data attributes for an element. These attributes are accessible via JavaScript.
Example: `<div data-id="123">`
8. `hidden`: Indicates that an element should be hidden from view.
Example: `<div hidden>`
9. `tabindex`: Specifies the order in which an element should receive focus when navigating with the keyboard (using the Tab key).
Example: `<input type="text" tabindex="1">`
10. `accesskey`: Defines a keyboard shortcut for focusing or activating an element.
Example: `<button accesskey="S">Save</button>`
11. `contenteditable`: Specifies whether the content of an element can be edited by the user.
Example: `<div contenteditable="true">Editable content</div>`
12. `spellcheck`: Specifies whether the browser should check the spelling of the element's content.
Example: `<input type="text" spellcheck="true">`
These are some of the commonly used global attributes in HTML. They can be used with various HTML elements to enhance functionality, accessibility, and styling.
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc