Next-Gen App & Browser
Testing Cloud

Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Next-Gen App & Browser Testing Cloud

How to make an image smaller in HTML?

If you're wondering how to make an image smaller in HTML, there are several simple ways to do it using HTML attributes or CSS. Resizing images helps improve page layout, load time, and responsiveness—making it an essential part of front-end development.

1. Using HTML Width and Height Attributes

You can directly define the size of an image using the width and height attributes in the <img> tag:


<img src="image.jpg" width="300" height="200" alt="Sample Image">

This is a quick way to make a picture smaller in HTML, but it’s better suited for fixed-size layouts.


2. Using Inline CSS

For more control over styling, you can resize the image using the style attribute:

<img src="image.jpg" style="width: 300px; height: auto;" alt="Sample Image">

Using height: auto maintains the original aspect ratio, preventing distortion.

3. Using CSS Classes

For reusable and cleaner code, define image dimensions in a CSS class and apply it to the <img> element:

<style>
  .small-img {
    width: 200px;
    height: auto;
  }
</style>

<img src="image.jpg" class="small-img" alt="Responsive Image">

This method is ideal when working on larger projects or applying consistent styles across multiple images.

4. Making Images Responsive

If you're working on a responsive website, use percentage-based widths or responsive CSS frameworks:

<img src="image.jpg" style="width: 100%; max-width: 400px; height: auto;" alt="Responsive Image">

This ensures the image scales based on the screen size while respecting a maximum width.

Test Your Website on 3000+ Browsers

Get 100 minutes of automation test minutes FREE!!

Test Now...

KaneAI - Testing Assistant

World’s first AI-Native E2E testing agent.

...
ShadowLT Logo

Start your journey with LambdaTest

Get 100 minutes of automation test minutes FREE!!

Signup for free