HTML scrolling Attribute

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 3 Examples
Deprecated & iframe

Introduction

The scrolling attribute was used on <iframe> elements to control scrollbar visibility when embedded content was larger than the iframe’s width or height. It accepted yes, no, or auto. In HTML5 the attribute is obsolete and deprecated—use CSS overflow on the iframe instead.

What You’ll Learn

01

<iframe> Only

Legacy embeds.

02

Deprecated

Obsolete in HTML5.

03

yes / no / auto

Three values.

04

CSS overflow

Modern replacement.

05

JavaScript

iframe.scrolling.

06

Legacy code

Read old markup.

Purpose of scrolling

The purpose of the scrolling attribute was to tell the browser whether an <iframe> should display scrollbars when the embedded document’s content overflows the iframe’s dimensions. This helped developers manage layout when embedding pages, widgets, or documents that might not fit the allotted space.

HTML5 replaced this HTML attribute with CSS. The mapping is straightforward: scrolling="yes" corresponds to overflow: scroll, scrolling="no" to overflow: hidden, and scrolling="auto" to overflow: auto.

⚠️
Do not use in new projects

Browsers may still reflect scrolling in the DOM for backward compatibility, but validators flag it as obsolete. Always prefer CSS overflow on <iframe> elements in modern web development.

📝 Syntax

Legacy syntax on an <iframe> (shown for recognition only—do not use in new projects):

scrolling-legacy.html
<iframe
  src="https://example.com/embed"
  width="600"
  height="400"
  scrolling="auto"
  title="Embedded content"
></iframe>

Modern equivalent with CSS:

iframe-modern.html
<iframe
  src="https://example.com/embed"
  width="600"
  height="400"
  style="overflow: auto;"
  title="Embedded content"
></iframe>

Syntax Rules

  • Historically valid on <iframe> and legacy <frame> elements.
  • Value must be one of: yes, no, or auto (case-insensitive).
  • Default behavior in legacy HTML was equivalent to auto.
  • Obsolete in HTML5—use CSS overflow instead.
  • Not valid on <div>, <body>, or other non-frame elements.
  • Always include a descriptive title on iframes for accessibility.

💎 Values

The scrolling attribute accepted three keyword values:

  • yes — Always show scrollbars in the iframe, even when content fits.
  • no — Hide scrollbars; overflow content may be clipped and unreachable without other navigation.
  • auto — Show scrollbars only when content overflows (browser decides).
scrolling-values.html
<!-- Legacy (avoid) -->
<iframe scrolling="yes" src="..."></iframe>
<iframe scrolling="no" src="..."></iframe>
<iframe scrolling="auto" src="..."></iframe>

<!-- Modern CSS mapping -->
<!-- yes  → overflow: scroll -->
<!-- no   → overflow: hidden -->
<!-- auto → overflow: auto -->

⚡ Quick Reference

GoalLegacy scrollingModern CSS
Scrollbars when neededscrolling="auto"overflow: auto
Always show scrollbarsscrolling="yes"overflow: scroll
Hide scrollbars / clipscrolling="no"overflow: hidden
Applicable element<iframe><iframe> or wrapper
JavaScript (legacy)iframe.scrolling = "auto"iframe.style.overflow = "auto"
Status in HTML5ObsoleteRecommended

Applicable Elements

ElementSupported?Notes
<iframe>ObsoletePrimary use; use CSS overflow today
<frame>ObsoleteLegacy framesets; frames are obsolete entirely
<div>NoUse CSS overflow on the container
<body>NoPage scrolling uses CSS on html/body

scrolling vs CSS overflow

FeaturescrollingCSS overflow
StatusDeprecatedStandard
Where to applyiframe attributeiframe style or class
FlexibilityThree keywords onlyauto, scroll, hidden, overlay, etc.
ValidatorFlags as obsoleteValid HTML5 + CSS
Use today?NoYes

Examples Gallery

Legacy scrolling on iframe, the CSS overflow replacement, and setting scrollbar behavior dynamically with JavaScript.

👀 Live Preview

Iframe with tall inline content and scrolling="auto" (legacy demo):

Content overflows the 100px height; scrollbars appear when needed. Prefer style="overflow:auto" in new code.

Example — Legacy iframe with scrolling

Historical markup you may encounter in older embeds:

index.html
<iframe
  src="https://example.com/embed"
  width="600"
  height="400"
  scrolling="yes"
  title="Embedded page"
></iframe>
Try It Yourself

How It Works

In this example, scrolling="yes" forced scrollbars to remain visible inside the iframe viewport, even when the embedded page was smaller than the frame.

Example — Modern CSS Replacement

Control iframe overflow with CSS instead of the deprecated attribute:

iframe-overflow.html
<style>
  .embed-frame {
    width: 600px;
    height: 400px;
    overflow: auto;   /* replaces scrolling="auto" */
    border: 1px solid #cbd5e1;
  }
  .embed-frame--clip {
    overflow: hidden; /* replaces scrolling="no" */
  }
</style>

<iframe
  class="embed-frame"
  src="https://example.com/embed"
  title="Embedded page"
></iframe>
Try It Yourself

How It Works

Apply overflow directly on the iframe or on a wrapper element. This gives you the same behavior as legacy scrolling values with better control and validator support.

Dynamic Values with JavaScript

Legacy code set scrolling at runtime; modern code sets style.overflow:

dynamic-scrolling.html
<iframe id="myIframe" src="..." title="Embed"></iframe>

<script>
  var frame = document.getElementById("myIframe");

  // Legacy (avoid in new code)
  frame.setAttribute("scrolling", "auto");

  // Modern replacement
  frame.style.overflow = "auto";
</script>
Try It Yourself

How It Works

When toggling scrollbar behavior based on user actions, change CSS overflow rather than the obsolete scrolling attribute. The DOM property may still exist for compatibility but should not be set in new projects.

♿ Accessibility

  • Never use scrolling="no" to trap users — Hiding scrollbars without providing another way to reach clipped content harms keyboard and screen reader users.
  • Always set title on iframestitle describes the embedded content for assistive technology.
  • Ensure content remains reachable — If you use overflow: hidden, confirm no essential information is cut off.
  • Respect user scroll preferences — Avoid disabling scrolling inside embedded documents unless intentional and documented.
  • Pair with sandbox when embedding third parties — See the sandbox attribute for security alongside layout control.

🧠 How scrolling Worked (Legacy)

1

Author sets scrolling on iframe

yes, no, or auto.

Legacy
2

Browser maps to overflow

Controls scrollbar display.

Rendering
3

HTML5 deprecates attribute

CSS overflow replaces it.

Standard
=

Use CSS overflow today

Same control, modern markup.

Browser Support

The scrolling attribute is obsolete. Browsers may still honor or reflect it for backward compatibility, but it is not part of modern HTML5. CSS overflow is supported everywhere.

⚠️ Obsolete · Use CSS

Deprecated since HTML5

Legacy attribute may still work in some browsers; CSS overflow is the reliable modern approach.

0% Recommended use
Google Chrome Legacy support / ignored
Obsolete
Mozilla Firefox Legacy support
Obsolete
Apple Safari Legacy support
Obsolete
Microsoft Edge Legacy support
Obsolete
scrolling on <iframe> Do not use

Bottom line: Recognize it in legacy embeds; replace with CSS overflow in new projects.

💡 Best Practices

✅ Do

  • Use CSS overflow: auto on iframes for modern scrollbar control
  • Size iframes appropriately so embedded content fits when possible
  • Include a descriptive title on every iframe
  • Remove scrolling when refactoring legacy pages
  • Test embeds across browsers after migrating to CSS overflow

❌ Don’t

  • Add scrolling to new iframe markup
  • Use scrolling="no" to hide content users still need to access
  • Assume scrolling="yes" works identically in all modern browsers
  • Confuse iframe scrolling with page-level body { overflow }
  • Embed untrusted pages without sandbox and security review

Conclusion

The scrolling attribute was a useful legacy tool for managing scrollbar visibility inside <iframe> elements. It is obsolete in HTML5 and should not appear in new documents.

Use CSS overflow for the same control with better flexibility and standards compliance. Understanding the old yes, no, and auto values helps when maintaining or migrating older embedded content.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about scrolling

Bookmark these before editing legacy iframes.

5
Core concepts
🖥️ 02

<iframe>

Legacy use only

Element
03

yes / no / auto

Three values

Values
🎨 04

CSS overflow

Modern replacement

Replace
05

Don’t clip

Keep content reachable

A11y

❓ Frequently Asked Questions

It controlled scrollbar visibility on <iframe> elements when embedded content overflowed. Values were yes, no, and auto. It is obsolete in HTML5.
<iframe> and legacy <frame> elements. Not on divs or the page body.
CSS overflow: auto, overflow: scroll, or overflow: hidden on the iframe element.
yes always showed scrollbars. auto showed them only when content overflowed. Map to overflow: scroll and overflow: auto respectively.
Legacy code used iframe.scrolling or setAttribute("scrolling", ...). Prefer iframe.style.overflow in new code.
Some browsers still honor it for compatibility, but behavior varies. CSS overflow is reliable and recommended.

Control iframe scrollbars the modern way

Compare legacy scrolling with CSS overflow in the Try It editor.

Try CSS overflow example →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful