HTML images are elements used to display visual content, such as photographs, illustrations, icons, or any other type of graphical representation, within a web page. The <img> tag is used in HTML to insert images into a document.
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Image Example</title>
</head>
<body>
<h1>Displaying an Image</h1>
<img src="example.jpg" alt="Example Image">
</body>
</html>
In this example:
- `<!DOCTYPE html>` declares the document type and version of HTML.
- `<html>` is the root element of the HTML document.
- `<head>` contains meta-information about the document, such as the character set and viewport settings.
- `<title>` sets the title of the document, which appears in the browser tab.
- `<body>` contains the visible content of the document.
- `<h1>` is a heading element that displays text.
- `<img>` is the image element. The `src` attribute specifies the URL or path to the image file. The `alt` attribute provides alternative text for accessibility purposes and is displayed if the image cannot be loaded.
Replace `"example.jpg"` with the actual URL or path to your image file.