<iframe width=””>

Sharing is caring!

Attribute of
<iframe> HTML Tag
What does <iframe width=""> do?
Specifies the width of an iframe.

Code Example

<iframe width="100%" height="500" src="https://html.com"></iframe>

Valid, but maybe don't use

Most of the styling attributes associated with <iframe> (and most other elements as well) have been deprecated in HTML5. However, width and [height] persist. So their use in specifying the size of an <iframe> is perfectly valid, but its a little hard to understand what the thinking was on this. Regardless of validity, the best design practice — especially from a responsive perspective — is to use CSS to control the sizing. This removes presentational information from your markup and allows you to more easily design for a wide range of browser sizes.

iframe.example {  width: 100%;  height: 600px; } 
<iframe class="example" src="/html5"></iframe> 
iframe.example { width: 100%; height: 600px; }
Adam is a technical writer who specializes in developer documentation and tutorials.

Browser Support for width