Components of Attribute
An HTML attribute consists of two primary components:
Attribute Name | Description |
---|---|
id | A unique identifier for an HTML element, used for styling or JavaScript interaction. |
class | Defines one or more class names for an element, used for styling and applying CSS rules. |
src | Specifies the source URL for external resources like images, audio, or video. |
href | Specifies the URL of the linked resource, typically used in anchor (a) elements for hyperlinks. |
alt | Provides alternative text for images, displayed if the image cannot be loaded or is unavailable. |
any_custom_attr | Describes any custom attribute name and its purpose in the HTML document. |
Syntax:
<element attribute_name= "attribute_value">
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