The width attribute on an <iframe> tag sets the width of the frame.
The width is specified in pixels -- without the ‘px‘ unit.
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>
The width attribute sets the width of the iframe.
HTML5 states that the width is defined in pixels, although some browsers also support %.
To define the width in % or other unit, use the CSS width property.
By default, the <iframe> width is 300 pixels.
<iframe width="value" />
Value | Description |
---|---|
pixels | A number (e.g. 750). |
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 |