How to add images in HTML page?

Hey, what’s up, guys. A webpage with only text is kind of boring. Adding images to a webpage makes it more engaging and cool. So, Do you wanna make your webpage look cool?

If you said yes then let’s learn how to add an image to a webpage.

To add an image in a webpage we use HTML <img> tag.

Let’s see an example.

<!DOCTYPE html>
<html>
    <head>
        <title>Add image</title>
    </head>

    <body>
        <img src="merry-christmas.jpg" alt="Winter Image" style="height: 200px; width: 200px;">
    </body>

</html>

Now let’s understand the above code.

As I mentioned earlier, we use the <img> tag to show an image on a webpage. You need to use two attributes with <img> tag src and alt.

Now, let’s understand these two attributes.

src – It is the source attribute. That means it specifies the path to the image you want to embed in the page.

alt – It is the alternate text attribute. That means it specifies an alternate text to be displayed in situations where an image can not be displayed because of a slow internet connection.

And width and height attribute is to specify the width and height of the image.

Now you know how to add images to a webpage.

Goodbye.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: