A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/html/html-img-width-attribute/ below:

HTML <img> width Attribute - GeeksforGeeks

HTML <img> width Attribute

Last Updated : 11 Jul, 2025

Width attribute in HTML <img> tags specifies the width of the image element in pixels or as a percentage of its containing element's width, controlling its visual size on the webpage.

Syntax:

<img width="pixels">

Attribute Values: They contain single value pixels which specify the width of the image in pixels. 

HTML <img> Width Attribute Examples:

Example: In this example, we display the GeeksforGeeks logo using the <img> tag with the width attribute set to 200px, adjusting the image's width on the webpage.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>
        HTML img width Attribute
    </title>
</head>

<body>
    <img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20190506164011/logo3.png" 
         alt="GeeksforGeeks logo"
         width="200px" 
         height="200px">
</body>

</html>

Output:

HTML image width attribute example Supported Browsers:

The browser supported by HTML <img> width attribute are listed below:



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4