HTML width Attribute


The width attribute in HTML specifies the width of an element, such as images, tables, or iframe. When used with an <img> element, it defines the width of the image in pixels or as a percentage of its containing block, allowing for the adjustment of the image's display size without altering the source file. For a <table>, it sets the width of the table itself, again in pixels or as a percentage, influencing how much space the table takes up in the layout. With <iframe>, it determines the width of the framed content area, which can be crucial for embedding external content like videos or other web pages. It's important to note that while the width attribute offers immediate and simple control over element sizing, CSS is often recommended for more flexible and responsive design approaches, as it separates content from styling and provides a wider range of design options.


<tagname width="pixels">


  • pixelsA numeric widthin pixels.

Applies To

The width attribute can be used on the following html elements.


<img src="images/sunset.jpg" alt="Image description" height="100" width="200">

Browser Support

The following table will show you the current browser support for the HTML width Attribute.

Edge Chrome Firefox Opera Safari
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview

Last updated by CSSPortal on: 29th March 2024