HTML5 – Images
Images are used to add visual content to a web page. In HTML5, images are inserted using the <img>
element.
Here is an example of how to insert an image in HTML5:
<img src="image.jpg" alt="A description of the image">
The src
attribute specifies the location of the image file. The alt
attribute provides a text description of the image, which is displayed if the image cannot be loaded or is not visible to the user (such as when using a screen reader).
Here is an example of an image with additional attributes:
<img src="image.jpg" alt="A description of the image" width="200" height="100">
The width
and height
attributes specify the size of the image in pixels. These attributes can be used to resize the image or to set the size of the image container.
You can style images using CSS, such as by adding a border, margin, or padding. You can also apply CSS classes or IDs to images to give them specific styles.