How to Make The Image Smaller in HTML [Upadated 2024]

In HTML we need different Images with different Sizes.
While inserting images for the first time, sometimes it's too big, and sometimes it's too small.
And we wonder How to make the Image Smaller in HTML.
Let's Fix it.

index.html

<html>
<head>
    <title>Make Image Smaller in HTML</title>
    <style>
        /*using CSS*/
        img {
            width: 100px;
            height: auto;
        }
    </style>
</head>
<body>
    <!-- Using HTML Attributes -->
    <img src='mycat.jpg' width="100px" height="auto" />
</body>
</html>

Steps to Make The HTML Image Smaller

Step 1: Select your Image in HTML
Step 2: Resize the Image (By HTML Attributes or CSS Properties)
Step 3: Save your HTML File
Step 4: Run your HTML file in a Web-browser

Step 1: Select your Image in HTML

In HTML we can use HTML Attributes or CSS Properties to resize Images.
So if you want to use HTML Attributes to resize your HTML Image, then you need to select the <Img> tag.

index.html (Selecting Image Tag)

<img src='mycat.jpg'/>

but if you are using CSS, then you need to select that Image Element by using Tagname, ClassName, or Id.
In this example, I am going to use TagName.

style.css (Selecting Image in CSS

img{
}
Ad

Need a Personal Tutor?

I am here to help you with your Programming journey. HTML, CSS, JavaScript, ReactJS, NextJS, C, C++, C#, SQL and more.

Less then 10$/hSee Plans100% Free Trial + Money Back Guaranty

Step 2: Resize the Image

As I've mentioned before,
we have two different methods to Resize Images in HTML.
By using HTML WIDTH and HEIGHT Attributes and by using CSS HEIGHT and WIDTH Properties.


so for HTML WIDTH and HEIGHT attributes, you just need to include them inside <img> tags and you can provide new Width and Height there.

index.html (Using HTML Attributes)

<img src='mycat.jpg' width="100px" height="auto" />

for CSS, you need to use Width and Height Properties.

styles.css (using CSS)

img{
  width: 100px;
  height: auto;
}

Step 3: Save your HTML File

Now after making all those changes, you need to Save it.
(You can use shortcuts like ctrl+s to Save your file or go to File>Save in your Code Editor.)

Step 4: Run your HTML file in a Web-browser

At the end, all you gotta do is to Run your HTML file in your Webbrowser to see your Results.
If your Image is Still too big or small, then you can go back to your Code editor and Tweak the Width value further.

How to Make The Image Smaller in HTML [Upadated 2024]

FAQ - How to Make The Image Smaller in HTML

From now on we will deuces all the Frequently asked questions related to our Topic "How to Make The Image Smaller in HTML"

Ad

Need a Personal Tutor?

I am here to help you with your Programming journey. HTML, CSS, JavaScript, ReactJS, NextJS, C, C++, C#, SQL and more.

Less then 10$/hSee Plans100% Free Trial + Money Back Guaranty

What is px in the image?

PX or Pixel is the smallest Element of an Image. So if we have a 300px image, This means this image consists of 300 Pixels.

What is an image ALT tag?

In HTML ALT attributes are used to specify an Alternative text.
So if the browser is unable to load the Image then it will display that Alternative ALT text there.

index.html

<img src='mycat.jpg' alt="A cat Image" />

Do images need alt?
Not actually, you can still load your Images without the ALT attribute, but it's always good to include the ALT attribute so you have something to display there as an Alternative text on Image loading failure.

How do you specify size in HTML?

In HTML we can use Height and Width Attributes to specify Element Size.
We can provide New Size values in Pixels like width="100px" and this will Resize our HTML Element width to 100px.

Can a PNG be scaled?

Yes,
all the Images like JPG, PNG, GIF, and TIFF are Scalable in HTML. You just need to include them inside HTML and you will be able to resize them using HTML Attributes or CSS Properties.

Ad

Need a Personal Tutor?

I am here to help you with your Programming journey. HTML, CSS, JavaScript, ReactJS, NextJS, C, C++, C#, SQL and more.

Less then 10$/hSee Plans100% Free Trial + Money Back Guaranty

How do I resize an image in HTML CSS?

In CSS, we can use Width and Height CSS Properties to Resize an Image.
You just need to Select your Image Element in CSS, use CSS Width Property to Resize the Width, and give it a new Width value and you are DONE.

styles.css

img {
  width: 100px;
  height: auto;
}

How to make an image smaller?

To make an Image Smaller, you just have to reduce the Width of your HTML image and it will eventually make your Image appear smaller on your HTML web page.

index.html

<img src='mycat.jpg' width="100px" />

How to shrink an image in CSS?

To shrink an image in CSS, you can use small height and width sizes.
Where you can any big image in smaller sizes like "100px".
To do that use CSS width: 100px Property.

index.html

<img src='mycat.jpg' width="100px" />

What is the HTML code for image size?

In HTML, we can use HEIGHT and WIDTH Attributes to change the HTML Image Size.

index.html

<html>
<head>
    <title>Make Image Smaller in HTML</title>
</head>
<body>
    <!-- Using HTML Attributes -->
    <img src='mycat.jpg' width="100px" />
</body>
</html>
Ad

Need a Personal Tutor?

I am here to help you with your Programming journey. HTML, CSS, JavaScript, ReactJS, NextJS, C, C++, C#, SQL and more.

Less then 10$/hSee Plans100% Free Trial + Money Back Guaranty

How to resize an image with div CSS?

If your Image is present inside a Div then in CSS you need to make sure that your DIV is taking enough space (for example 100% of the available width)
then you can select the Image from the DIV by using div < img.
Use the Height and Width CSS Properties to resize your Image.

index.html

<html>
<head>
    <title>Image inside a Div</title>
    <style>
      div{
      	width: 100%;
      }
      div > img {
        width: 400px;
        height: auto;
      }
    </style>
</head>
<body>
  <div>
    <img src='mycat.jpg'/>
  </div>
</body>
</html>

Where div > img means, Select the IMG tag from Div or Inside the Div.

Ad

Need a Personal Tutor?

I am here to help you with your Programming journey. HTML, CSS, JavaScript, ReactJS, NextJS, C, C++, C#, SQL and more.

Just 10$/hSee Plans100% Free Trial + Money Back Guaranty
Logo