Open In App

How to Insert Image in HTML from Folder?

This article provides a complete overview on how to insert image in HTML code form folder. Images into a webpage is a crucial aspect of web design that enhances its visual appeal and user engagement. HTML provides various methods to insert images from a folder into your web pages.

Method 1: Using the <img> Tag

The <img> tag is the basic method to insert an image in HTML. The src attribute specifies the path to the image file.

<!DOCTYPE html>
<html>

<head>
    <title>
        Insert an Image in HTML from a Folder
    </title>
</head>

<body>
    <h3>Insert an Image in HTML from a Folder</h3>

    <img src="Geeks/HTML-tutorial.jpg" alt="HTML Tutorial"
        width="350px" height="230px">
</body>

</html>

Output:

image-from-folder-1

Explanation:

Method 2: Using CSS Background Image

You can also use CSS to set an image as the background of an HTML element.

<!DOCTYPE html>
<html>

<head>
    <title>
        Insert an Image in HTML from a Folder
    </title>

    <style>
        .background-image {
            width: 350px;
            height: 230px;
            background-image: url('Geeks/HTML-tutorial.jpg');
            background-size: cover;
        }
    </style>
</head>

<body>
    <h3>Insert an Image in HTML from a Folder</h3>

    <div class="background-image"></div>
</body>

</html>

Output:

image-from-folder-1

Explanation:

Article Tags :