Why HTML5 Iframe Width Isn't The Best Option To Control Sizing »

Skip to content HTML / HTML Frames Are Obsolete In HTML5: Here's How To Make Them Responsive / Using The HTML Tag To Create Inline Frames: Here's How / Why HTML5 Iframe Width Isn't The Best Option To Control SizingDisclosure: Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page. Learn moreAttribute ofUsing The HTML Tag To Create Inline Frames: Here's HowWhat does Why HTML5 Iframe Width Isn't The Best Option To Control Sizing 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 WoodAdam is a technical writer who specializes in developer documentation and tutorials.

Browser Support for width

iefirefoxchromeedgesafariopera
AllAllAllAllAllAll

Post navigation

The Student’s Guide To Citation Styles: Here’s When (And How) To CiteHTML Img Alt Tags For SEO Best Practice - Search Engines Love Them

Search HTML.com

Search for:

Most Popular

  • <var> HTML Tag306 views
  • What Is Doxing? (And Why Is It So Scary?): An Infographic85 views
  • New Audio HTML Element: Master It Out Now With Our Code Example62 views
  • The Web Worker's Stress Busting Toolbox: 50 Tips to Improve Your Life43 views
  • <meter> HTML Tag41 views
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok

Từ khóa » Html Size Iframe