HTML

HTML Images


5. Images:

  • <img> tag is used to embed an image in an HTML document.
  • The src attribute specifies the source (URL or file path) of the image. In this example, it is set to "example.jpg".
  • The alt attribute provides alternative text for the image. It is displayed if the image cannot be loaded or for accessibility purposes.
  • The width and height attributes set the dimensions of the image. These attributes are optional and can be used to control the size of the displayed image.

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Image Example</title>
</head>
<body>

<!-- Example of using the <img> tag -->
<img src="example.jpg" alt="An example image" width="300" height="200">

</body>
</html>