HTML attributes provide additional information about an element, such as its size or color. Attributes can be added to HTML tags using the tag's opening tag. Here are some examples of HTML attributes:
src: The src attribute is used to specify the URL of an image, video, or audio file that is embedded in the web page using the <img>, <video>, or <audio> tag. Here is an example:
<img src="image.jpg" alt="A picture of a cat">
In this example, the src attribute specifies the URL of the image file, and the alt attribute provides a text description of the image.
href: The href attribute is used to specify the URL of a web page that a link goes to. Here is an example:
<a href="http://www.example.com">Visit Example.com</a>
In this example, the href attribute specifies the URL of the web page that the link goes to.
width and height: The width and height attributes are used to specify the dimensions of an image or video in pixels. Here is an example:
<img src="image.jpg" alt="A picture of a cat" width="500" height="300">
In this example, the width attribute specifies the width of the image in pixels, and the height attribute specifies the height of the image in pixels.
style: The style attribute is used to apply CSS styles to an element. Here is an example:
<p style="color: red; font-size: 24px;">This is a red paragraph with font size 24px</p>
In this example, the style attribute applies CSS styles to the <p> tag, setting the color to red and the font size to 24 pixels.
class and id: The class and id attributes are used to identify elements for styling and scripting purposes. Here is an example:
<div class="container" id="main-content">
<p>This is the main content of the page.</p>
</div>
In this example, the class attribute identifies the <div> tag as part of the "container" class, and the id attribute identifies the <div> tag as the "main-content" element.
These are just a few examples of HTML attributes. There are many more attributes that can be used to customize the appearance and functionality of HTML elements.
No comments:
Post a Comment