HTML Attributes
HTML Attributes
HTML attributes provide extra information about an HTML element. They are always written in the start tag and usually come in name=”value” format.
Example
-
hrefis the attribute -
"https://google.com"is the value
Common HTML Attributes
| Attribute | Used With | Purpose |
|---|---|---|
href |
<a> |
Defines the link URL |
src |
<img> |
Defines image file path |
alt |
<img> |
Provides alternative text |
style |
Any tag | Adds inline CSS styling |
id |
Any tag | Unique identifier |
class |
Any tag | Used to group elements |
Another Example
Here:
-
src,alt, andwidthare attributes.
Attributes make HTML elements more meaningful and functional.
