width
width attribute
The HTML width
attribute sets the width for elements like <img>
, <table>
, and <iframe>
. For an <img>
, it adjusts the display width in pixels or percentages without modifying the source file. For a <table>
, it controls the table’s width within the layout. In an <iframe>
, it defines the width of the embedded content area. While the width
attribute offers a simple way to make adjustments, using CSS is generally recommended for more flexible and responsive designs, as it separates styling from content and provides greater design options.
Syntax
<tagname width="pixels">
Example

<img src="img.jpg" alt="Red Rose" height="100" width="200">
Values
- pixels
- A numeric widthin pixels.
Applies To
The width
attribute can be applied to the following HTML elements:
Conclusion
The width
attribute in HTML specifies the width of elements such as <img>
, <table>
, and <iframe>
, usually in pixel values. Although it provides a simple method to adjust element sizes, using CSS is generally preferred for greater flexibility and responsiveness. CSS offers more control over layout and design, making it easier to adapt to different devices.
usemap
The usemap attribute in HTML associates an image with an image map, enabling certain regions of the image to be clickable and guiding users to different destinations.
Event
HTML event attributes define how elements react to user interactions or browser actions, triggering JavaScript for events like clicks, key presses, or page loads. This makes web pages more interactive and dynamic.