HTML Attributes
Attributes are defined within the start tag of an element and are specified as name-value pairs and HTML attributes are additional pieces of information that can be added to HTML elements to modify their behavior or provide extra details.
Below, There are some attributes mentioned that are commonly used in HTML page
- Class
- ID
- Style
- SRC
- Alt
- Disabled
- Placeholder
CLASS
CLASS attribute specifies one or more class names for an element, allowing you to apply CSS styles or target elements using JavaScript.
For Example:
<div class="container">
<!-- Element content -->
</div>
ID
ID attribute provides a unique identifier for an element, which can be used to target the element with CSS or JavaScript.
For Example:
<h1 id="title">Hello, World!</h1>
STYLE
It allows inline CSS styles to be applied directly to an element.
For Example:
<p style="color: red; font-size: 16px;">This is a red paragraph with a font size of 16 pixels.</p>
SRC
It specifies the source URL or path for an element, such as an image or script.
For Example:
<img src="images/picture.jpg" alt="A beautiful picture">
HREF
It defines the destination URL or location for anchor (<a>) elements.
For Example:
<a href="https://www.example.com">Visit Example.com</a>
alt
It provides alternative text for an image when it cannot be displayed or read by screen readers.
For Example:
<img src="images/picture.jpg" alt="A beautiful picture">
Disabled
Disables an input or button element, preventing user interaction.
For Example:
<input type="text" disabled>
Placeholder
It specifies a short hint or sample value for an input element.
For Example:
<input type="text" placeholder="Enter your name">
These are just a few examples of HTML attributes, actually, different elements have different attributes available to them, so it's important to refer to documentation or references for specific elements and their attributes.