HTML Images
The HTML <img> tag is used to embed an image in web pages by linking them. It creates a placeholder for the image, defined by attributes like src, width, height, and alt, and does not require a closing tag.
There are two ways to insert the images into a webpage:
- By providing a full path or address (URL) to access an internet file.
- By providing the file path relative to the location of the current web page file.
Basic Example of the <img> Tag:
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″> <meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<title>HTML</title>
</head>
<body>
<img src=
“https://media.sunitarai.org/wp-content/uploads/20210915115837/gfg3-300×300.png”
alt=”GFG image” />
</body>
</html>
In this example:
- The <img> tag is used to embed an image into the webpage.
- src attribute: Specifies the source URL of the image, which in this example is https://media.sunitarai.org/wp-content/uploads/20210915115837/gfg3-300×300.png. The image is loaded from this URL when the webpage is accessed.
- alt attribute: Provides alternative text for the image, “GFG image,” which describes the image content. If, for any reason, the image cannot be displayed, the text “GFG image” will be shown instead.