HTML Global Attributes
Global attributes apply to all types of HTML tags. Some commonly used global attributes include:
Attribute | Description |
---|---|
class | Groups elements and allows styling. |
style | Inline CSS styles. |
src | Specifies the source of various resources, such as image URLs for the img element, video URLs for the video element, and audio URLs for the audio element. |
contenteditable | Determines whether the content within the element is editable. |
role | Specifies the element’s accessibility role. |
tabindex | Determines the order of focus during keyboard navigation. |
id | Assigns a unique identifier to an element, allowing targeting with CSS or JavaScript. |
href | Defines the hyperlink destination within the a element, enabling navigation. |
alt | Provides alternative text for images, essential for accessibility and SEO. |
title | Creates a tooltip that appears when a user hovers over the element. |
lang | Specifies the language of the element’s content, aiding with translation and accessibility. |
HTML Attributes
HTML attributes provide additional information about elements within an HTML document. Every HTML element can have attributes. Attributes are always defined in the start tag. They are specified using a name/value pair format, where the attribute name defines the property, and its value provides specific details, like name=”value”. These attributes impact content display and interaction on web pages.
Let’s explore the key aspects of HTML attributes:
Table of Content
- HTML Global Attributes
- HTML src Attribute
- HTML alt Attribute
- HTML width and height Attribute
- HTML id Attribute
- HTML title Attribute
- HTML href Attribute
- HTML style Attribute
- HTML lang attribute
Contact Us