width (HTML attribute)

Spec
Depr. Version
No HTML 4.01
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2+
Full Full Full Full Full

Syntax

width="width of window in pixels or percentage"

Description

As the iframe is ‘free-floating’, and not governed by the height or width of the parent window (as normal frames inside a frameset are), you need to let the browser know how wide it should be on the page (if no width is specified, the browser will apply a value of around 300 pixels). Note that you can also use CSS to set the width of the iframe, which is the preferred method for styling this element.

Example

The iframe's width set to 400 pixels

<iframe src="iframe-content.html" width="400"
height="200" frameborder="1">
<p>Your browser does not support iframes.
That kinda sucks, eh?</p>
</iframe>

Value

A number representing the width of the iframe in pixels or as a percentage.

Compatibility

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full

Every browser listed supports this attribute.

User-contributed notes

There are no comments yet.

Related Products