In HTML, you can insert images using the <img>
element.
Example:
<img src="image.jpg" alt="Description of image">
In Above example, the src
attribute specifies the URL of the image file, and the alt
attribute provides a text description of the image that is displayed if the image cannot be loaded or read by a screen reader.
You can also specify additional attributes such as the image width and height
Example:
<img src="image.jpg" alt="Description of image" width="300" height="200">
You can also use relative or absolute paths for the src
attribute to link to images in different directories or on different servers
Examples:
<!-- Relative path to image in same directory as HTML file -->
<img src="image.jpg" alt="Description of image">
<!-- Absolute path to image on different server -->
<img src="https://example.com/image.jpg" alt="Description of image">
You can also use CSS to style images, such as adding borders, margins, or other effects
Example:
<img src="image.jpg" alt="Description of image" style="border: 1px solid black; margin: 10px;">
Note, that it is important to optimize image files for the web by reducing their file size and dimensions as much as possible without sacrificing image quality, as large or uncompressed images can slow down web page loading times.