CSS Portal

HTML width Attribute

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

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.

Syntax

<tagname width="pixels">

Values

  • pixelsA numeric widthin pixels.

Example

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

Browser Support

The following information will show you the current browser support for the HTML width attribute. Hover over a browser icon to see the version that first introduced support for this HTML attribute.

This attribute is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 29th March 2024

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!