Friday, July 26, 2024

HTML Images


HTML images are embedded using the <img> tag, which does not have a closing tag. The src attribute specifies the path to the image file, while the alt attribute provides alternative text for accessibility and displays if the image fails to load. The width and height attributes can be used to define the dimensions of the image. Proper use of images enhances the visual appeal and user experience of a webpage.

Examples:

<img src="image.jpg" alt="Description of the image">

<img src="image.jpg" alt="Description of the image" width="500" height="300">

<img src="https://www.example.com/image.jpg" alt="Example Image">


HTML Code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>HTML Tutorial</title>
</head>
<body>
    <h1>HTML Images</h1>
    <p>HTML images are defined with the <code>&lt;img&gt;</code> tag.</p>
    <pre>
        &lt;img src="image.jpg" alt="Description of image"&gt;
    </pre>
<img src="https://www.example.com/image.jpg" alt="Example Image">
</body>
</html>

The Output of the above code:


HTML Tutorial - Page 8

HTML Images

HTML images are defined with the <img> tag.

        <img src="image.jpg" alt="Description of image">
    
Example Image