common HTML Attributes



 

In HTML, an attribute is a modifier of an HTML element that provides additional information about the element. Attributes are always included in the opening tag of an element and typically come in name/value pairs, like name="value"

<a href="https://www.example.com" target="_blank">Visit Example</a>
 common Html Attribute
Here are some common HTML attributes that are frequently used:
1. id
Purpose: Uniquely identifies an element on the page.
Example
<div id="header">This is the header</div>

2. class
Purpose: Assigns one or more class names to an element, typically used for styling and scripting.Example:
<p class="intro">This is an introductory paragraph.</p>

3. href
Purpose: Specifies the URL of a link.
Example:
<a href="https://www.example.com">Visit Example</a>

4. src
Purpose: Specifies the source of an image, video, or other media.
Example:
<img src="image.jpg" alt="Description of image">

5. alt
Purpose: Provides alternative text for an image if it cannot be displayed.
Example:
<img src="image.jpg" alt="Description of image">

6. title
Purpose: Adds a tooltip text that appears when the mouse hovers over the element.
Example:
<p title="This is a tooltip">Hover over this text.</p>

7. style
Purpose: Adds inline CSS styles to an element.
Example:
<h1 style="color: blue; text-align: center;">Hello, World!</h1>

8. target
Purpose: Specifies where to open the linked document.
Example:
<a href="https://www.example.com" target="_blank">Open in a new tab</a>

9. type
Purpose: Specifies the type of input in form elements or type of script/style in other elements.
Example:<input type="text" name="username">

10. name
Purpose: Assigns a name to an element, often used in forms to identify the form fields.
Example:
<input type="text" name="username">


Post a Comment

0 Comments