HTML frameborder Attribute

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 3 Examples
iframes & Legacy Frames

What You’ll Learn

The frameborder attribute controls whether a visible border is drawn around <iframe> elements and legacy <frame> elements. Use frameborder="0" for a seamless embed or frameborder="1" to show a border. In modern HTML, CSS is often preferred over this attribute.

01

Border on/off

Values 0 and 1.

02

iframe

Most common today.

03

Legacy frame

Frameset era.

04

CSS alt

border: none;

05

frameBorder

JS property name.

06

Obsolete

Still supported.

Purpose of frameborder Attribute

The frameborder attribute determines whether a visible border should be drawn around embedded frames. It is typically applied to <iframe> elements when embedding external content, or to legacy <frame> elements inside obsolete <frameset> layouts.

Frames are deprecated for page layout, but frameborder remains useful for understanding older web pages and for quickly toggling iframe borders in simple examples.

💡
Modern alternative: CSS

In HTML5, frameborder on <iframe> is obsolete. Prefer style="border: none;" or iframe { border: none; } in CSS for borderless embeds.

📝 Syntax

Add frameborder to an <iframe> with 0 or 1:

frameborder.html
<!-- Border visible -->
<iframe src="example.html" frameborder="1"></iframe>

<!-- No border (common for embeds) -->
<iframe src="example.html" frameborder="0"></iframe>

Syntax Rules

  • Valid on <iframe> and legacy <frame> elements.
  • Values are "0" (no border) or "1" (border shown).
  • On iframe, the attribute is obsolete in HTML5 but browsers still honor it.
  • For new projects, CSS border gives finer control over width, color, and style.

💎 Values

The frameborder attribute accepts two main values:

  • 1 — A border is drawn around the frame. This was the historical default in many browsers.
  • 0 — No border is drawn. Common for embedded maps, videos, and widgets that should blend into the page.
frameborder-values.html
<iframe src="/map" frameborder="0" width="600" height="400"></iframe>

⚡ Quick Reference

ValueEffectTypical Use
0No borderEmbedded widgets, seamless embeds
1Border visibleLegacy demos, visible separation
CSS equivalentborder: none;Modern recommended approach
Element<iframe>, <frame>Embedded browsing contexts
JS propertyiframe.frameBorderString "0" or "1"
HTML5 statusObsolete on iframeStill works in browsers

Applicable Elements

ElementSupported?Notes
<iframe>YesPrimary modern use; attribute obsolete but supported
<frame>Yes (legacy)Inside obsolete framesets
<img>, <div>NoUse CSS border instead

frameborder vs CSS border

ApproachExampleWhen to Use
frameborder="0"<iframe frameborder="0">Quick legacy/simple embeds
CSS borderiframe { border: none; }Modern projects (recommended)
Inline stylestyle="border:0"One-off borderless iframe

Examples Gallery

iframe with border, borderless embed, legacy frameset frames, and dynamic frameBorder with JavaScript.

👀 Live Preview

Compare bordered vs borderless iframe styling (simulated):

frameborder="1"
frameborder="0"

Implementation Example — iframe with Border

Here’s a basic example demonstrating the use of the frameborder attribute within an <iframe> element:

index.html
<iframe src="example.html" frameborder="1" width="400" height="300"></iframe>
Try It Yourself

How It Works

In this example, frameborder="1" tells the browser to draw a border around the iframe, visually separating the embedded document from the parent page.

Example — Borderless iframe Embed

Most modern embeds remove the default border for a cleaner look:

borderless-iframe.html
<iframe
  src="https://example.com/widget"
  frameborder="0"
  width="100%"
  height="400"
  title="Embedded widget"></iframe>

<!-- Modern CSS equivalent -->
<style>
  iframe { border: none; }
</style>
Try It Yourself

How It Works

frameborder="0" removes the default iframe border. For new code, CSS border: none achieves the same result with more styling flexibility.

Dynamic Values with JavaScript

You can change the frameborder attribute dynamically based on user interaction:

index.html
<iframe id="dynamicFrame" src="example.html"></iframe>

<script>
  var frame = document.getElementById("dynamicFrame");
  frame.frameBorder = "0";
</script>
Try It Yourself

How It Works

The script sets frameBorder to "0" on the iframe, removing the border at runtime. You can toggle between "0" and "1" based on UI state.

♿ Accessibility

  • Always set title on iframes — Describes embedded content for screen reader users.
  • Borders are visual only — Removing borders does not remove the need for accessible iframe labels.
  • Consider focus management — Users must be able to tab into iframe content when appropriate.
  • Avoid excessive nesting — Frames and iframes add complexity for assistive technology.

🧠 How frameborder Works

1

Author sets frameborder

0 hides border; 1 shows border.

Markup
2

Browser renders iframe

Embedded document loads inside frame.

Render
3

Border drawn or omitted

Visual separation from parent page.

Display
=

Controlled embed appearance

Seamless or framed—your choice.

Browser Support

The frameborder attribute is widely supported on iframes despite being obsolete in HTML5. CSS borders work universally for modern styling.

Obsolete but supported

Universal iframe border control

Browsers honor frameborder; CSS is preferred for new code.

99% Browser support
Google Chrome Fully supported
Full support
Mozilla Firefox Fully supported
Full support
Apple Safari Fully supported
Full support
Microsoft Edge Fully supported
Full support
frameborder attribute 99% supported

Bottom line: Use frameborder for legacy compatibility; prefer CSS border in new projects.

💡 Best Practices

✅ Do

  • Use frameborder="0" or CSS for seamless embeds
  • Add a descriptive title on every iframe
  • Prefer CSS border in new HTML5 projects
  • Consider usability and accessibility when embedding content
  • Test embed appearance across browsers

❌ Don’t

  • Rely on framesets for modern page layout
  • Omit title on iframes
  • Assume borderless iframes need no accessibility work
  • Use frame.frameborder in JS (use frameBorder)
  • Nest many iframes without clear purpose

Conclusion

Although frames are considered deprecated for page layout, the frameborder attribute remains relevant for controlling borders around iframes and legacy frame elements. Understanding how to use this attribute helps when maintaining older websites or working with simple embeds.

For new projects, combine borderless iframes with CSS styling and always include accessible title attributes on embedded content.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about frameborder

Bookmark these before embedding iframes.

5
Core concepts
📄 02

On iframe

Main use today.

Scope
🎨 03

Use CSS

Modern approach.

Best practice
⚙️ 04

frameBorder

JS camelCase.

Script
05

Add title

iframe a11y.

A11y

❓ Frequently Asked Questions

It controls whether a visible border is drawn around an iframe or legacy frame element. 0 hides the border; 1 shows it.
Set frameborder="0" or use CSS iframe { border: none; }.
It is obsolete on iframe in HTML5 but still works in browsers. CSS is the recommended replacement.
<iframe> and legacy <frame> elements.
Use iframe.frameBorder = "0" (camelCase) or setAttribute("frameborder", "0").
No for new sites. Framesets are obsolete. Use iframes with CSS for embedded content.

Embed content cleanly

Practice borderless iframes with frameborder="0" in the Try It editor.

Try borderless iframe 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.

3 people found this page helpful