Attributes of HTML
HTML attributes are added to HTML elements to provide additional information about the element. They consist of a name and a value, separated by an equals sign (=). Attributes are used to:
1. _Modify behavior_: Change the default behavior of an element.
2. _Provide metadata_: Add extra information about the element.
3. _Style content_: Control the visual presentation of an element.
Here are some common HTML attributes:
1. _href_: Specifies the link URL for the `<a>` element.
2. _src_: Specifies the image URL for the `<img>` element.
3. _alt_: Provides alternative text for the `<img>` element.
4. _title_: Specifies a tooltip or hover text for an element.
5. _class_: Assigns a class name to an element for styling or JavaScript manipulation.
6. _id_: Assigns a unique ID to an element for styling or JavaScript manipulation.
7. _style_: Inline styling for an element.
8. _width_ and _height_: Specify the dimensions of an image or other element.
9. _placeholder_: Specifies a placeholder text for a form input.
10. _required_: Specifies that a form input is required.
Attributes are added to the opening tag of an HTML element, like this:
```
<tag attribute="value">Content</tag>
```
For example:
```
<a href="(link unavailable)">Visit Example</a>
```
In this example, `href` is an attribute of the `<a>` element, with the value `(link unavailable)`.
0 टिप्पणियाँ