HTML <iframe> width Attribute

The width attribute on an <iframe> tag sets the width of the frame. The width is specified in pixels -- without the ‘px‘ unit.

Example

#

A width attribute on an <iframe> element.
This element has a width attribute and a CSS width property; CSS width takes precedence, i.e. wins.

<iframe src="https://www.wikipedia.org/wiki/Vincent_van_Gogh"
        width="400" style="height:400px;width:100%"></iframe>

Using width

The width attribute sets the width of the iframe.

HTML5 states that the width is defined in pixels, although some browsers also support %.

If % or another unit is required, use the CSS width property.

By default, the <iframe> width is 300 pixels.


Syntax

<iframe width="value" />

Values

#

Value Description
pixels A number (e.g. 750).

Browser support

Here is when width support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <iframe>
Guides