Introduction
HTML Attributes
Attributes give extra information about an element. They always go inside the opening tag and are written as name="value".
Syntax:
<tagname attribute="value">Content</tagname><a href="https://techsnow.com" target="_blank">Visit TechSnow</a>
<img src="logo.png" alt="TechSnow logo" width="120">Common attributes
| Attribute | Used on | Purpose |
|---|---|---|
href | <a>, <link> | The address a link points to. |
src | <img>, <script>, <video> | The file to load. |
alt | <img> | Alternative text describing an image. |
id | Any element | A unique name for one element. |
class | Any element | A reusable name for styling groups of elements. |
style | Any element | Inline CSS styles. |
title | Any element | Extra info shown as a tooltip on hover. |
lang | <html> | The language of the page. |
Boolean attributes
Some attributes need no value. Just writing them switches the feature on.
<input type="checkbox" checked>
<button disabled>Can't click me</button>
<video src="intro.mp4" controls autoplay muted></video>