HTML attributes provide extra information about HTML elements. They help control the behavior, appearance, or functionality of elements on a webpage.
name="value".
HTML attributes give additional information about an element. They are always written inside the start tag. Most attributes come in name and value pairs.
<a href="https://example.com">Visit Example</a>
Here, href is the attribute and "https://example.com" is its value.
The id attribute uniquely identifies an element.
It is used when we want to select one specific element.
<div id="main-content"></div>
The class attribute assigns one or more class names to an element.
It is used for CSS styling and JavaScript.
<p class="text-center large-text"></p>
The style attribute is used to apply inline CSS styles.
<h1 style="color: blue; font-size: 24px;">Welcome</h1>
The href attribute specifies the URL of a link.
<a href="https://example.com">Visit Example</a>
The src attribute specifies the source of an image or embedded media.
<img src="image.jpg" alt="Sample Image">
The alt attribute gives alternative text for an image if the image cannot be displayed.
<img src="logo.png" alt="Company Logo">
The title attribute provides extra information as a tooltip when the user hovers over an element.
<button title="Click here to submit">Submit</button>
Data attributes are custom attributes that start with data-.
They are used to store extra information.
<div data-user-id="12345"></div>
The type attribute specifies the type of an input element or button.
<input type="text" placeholder="Enter name">
The placeholder attribute shows hint text inside an input box.
<input type="email" placeholder="Enter your email">
The disabled attribute makes an element inactive.
<button disabled>Submit</button>
The value attribute defines the value of input, option, or button elements.
<input type="text" value="Default Text">
The action attribute tells where to send form data when the form is submitted.
<form action="/submit" method="POST"></form>
The method attribute defines the HTTP method used for form submission.
Common values are GET and POST.
<form method="POST"></form>
The target attribute defines where to open the linked document.
<a href="https://example.com" target="_blank">Open in new tab</a>
The rel attribute defines the relationship between the current page and the linked page.
<a href="https://example.com" rel="nofollow">Example</a>
The autocomplete attribute tells the browser whether to suggest previously entered values.
<input type="text" autocomplete="off">
The required attribute makes an input field mandatory before submitting a form.
<input type="email" required>
The readonly attribute makes an input field read-only.
The user can see the value but cannot edit it.
<input type="text" value="Fixed Value" readonly>
The checked attribute preselects a checkbox or radio button.
<input type="checkbox" checked>
class, id, style, and title can be used on many elements.checked, disabled, and readonly are boolean attributes.Which attribute specifies the URL of a hyperlink?