JavaScript Document designMode Property

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Standard HTML
Instance property

What You’ll Learn

Document.designMode is a read/write instance property that controls whether the entire document is editable. Learn the "on" / "off" values, the classic iframe editor pattern, how it differs from contenteditable, and five examples with try-it labs.

01

Kind

Read / write

02

Values

on / off

03

Default

"off" (spec)

04

Scope

Whole document

05

Classic use

iframe editor

06

vs

contenteditable

Introduction

Sometimes you want users to edit HTML the way they type in a word processor. One older but still supported approach is to turn on document design mode: the browser treats the whole document as an editable surface.

MDN: document.designMode controls whether the entire document is editable. Valid values are "on" and "off". The specification defaults to "off" (Firefox follows this; modern Chrome does too).

💡
Whole page vs one box

Turning designMode on for the main page makes navigation chrome and scripts’ host page editable too—usually you enable it on an iframe’s contentDocument instead (MDN’s example), or use contenteditable on a single element.

Related Document tutorials: defaultView, currentScript, Document constructor.

Understanding Document.designMode

An instance property on Document you can both read and write. It stores a string switch for document-wide editing.

  • Values"on" or "off" (MDN / spec).
  • Default — meant to be "off"; Firefox and modern Chrome agree.
  • Legacy — older Chrome/IE used "inherit"; IE6–10 capitalized values (MDN).
  • Effect — when on, the user can type and edit content across the document.
  • Common patterniframe.contentDocument.designMode = "on" (MDN).

📝 Syntax

JavaScript
// Read
document.designMode

// Write
document.designMode = "on";
document.designMode = "off";

Value

A string: "on" or "off", indicating whether design mode is (or should be) enabled (MDN).

Iframe pattern (MDN)

JavaScript
iframeNode.contentDocument.designMode = "on";

⚡ Quick Reference

GoalCode / note
Read modedocument.designMode
Enable editingdocument.designMode = "on"
Disable editingdocument.designMode = "off"
Editable iframeiframe.contentDocument.designMode = "on"
Element-only editel.contentEditable = "true"
Valid values"on" / "off"

🔍 At a Glance

Four facts about document.designMode.

Type
string

on / off

Access
get + set

Read / write

Default
"off"

Per spec

Scope
document

Whole page

📋 Historical value quirks (MDN)

Era / engineBehavior
Specification / FirefoxDefault "off"; values on / off
Chrome 43+Default "off"; "inherit" no longer supported
Earlier Chrome / IECould default to "inherit"
IE6–10Value often capitalized

For new code, only rely on lowercase "on" and "off".

Examples Gallery

Examples follow MDN Document: designMode. Prefer iframe demos for safe editing. Use View Output or Try It Yourself for each case.

📚 Getting Started

Read the property and enable whole-document editing.

Example 1 — Read document.designMode

Most pages start with design mode off.

JavaScript
console.log(document.designMode);
// "off" on modern browsers (spec default)
Try It Yourself

How It Works

Reading the property does not change editability—it only reports the current switch.

Example 2 — Turn Design Mode On

After this, click the page body and type to edit (demo pages only).

JavaScript
document.designMode = "on";
console.log(document.designMode); // "on"
Try It Yourself

How It Works

The whole document becomes an editing host. Turn it off again with "off" when finished.

📈 Toggle, Iframe & Alternatives

Practical patterns for editors and safer alternatives.

Example 3 — Toggle On / Off

A button that flips design mode for quick demos.

JavaScript
function toggleDesignMode() {
  document.designMode =
    document.designMode.toLowerCase() === "on" ? "off" : "on";
  console.log("Now:", document.designMode);
}

toggleDesignMode();
Try It Yourself

How It Works

Normalize with toLowerCase() if you ever deal with legacy capitalized values (old IE).

Example 4 — Editable Iframe Document (MDN)

MDN’s recommended pattern: enable design mode on the iframe’s document.

JavaScript
const iframe = document.querySelector("iframe");
iframe.addEventListener("load", () => {
  iframe.contentDocument.designMode = "on";
  console.log(
    "iframe designMode:",
    iframe.contentDocument.designMode
  );
});
Try It Yourself

How It Works

Wait for load so contentDocument is ready. Same-origin iframes only.

Example 5 — Prefer contenteditable for One Box

Edit a single region without making the whole document editable.

JavaScript
const box = document.getElementById("editor");
box.contentEditable = "true";
console.log("document.designMode still:", document.designMode); // "off"
console.log("box editable:", box.isContentEditable); // true
Try It Yourself

How It Works

Element-level editing keeps buttons, nav, and scripts outside the editable region.

🚀 Common Use Cases

  • Classic WYSIWYG — editable iframe document with a formatting toolbar.
  • HTML mail composers — legacy clients sometimes used designMode iframes.
  • Teaching / demos — show how browsers expose document-wide editing.
  • Quick prototyping — turn on designMode to tweak live markup (local only).
  • Prefer contenteditable — for modern in-page editors scoped to one element.
  • Not for production CMS by default — evaluate accessibility, sanitization, and modern editor libraries.

🧠 How designMode Editing Works

1

Document starts non-editable

designMode is typically "off".

Default
2

You set "on"

Often on an iframe’s contentDocument (MDN).

Enable
3

User types in the document

Browser updates the live DOM as they edit.

Edit
4

Read HTML / turn off

Serialize with innerHTML / documentElement.outerHTML, then set "off".

📝 Notes

  • MDN does not mark this property Deprecated, Experimental, or Non-standard — no status banner above.
  • Valid values: "on" and "off"; spec default "off".
  • Prefer enabling on an iframe document rather than the whole site chrome.
  • Sanitize any HTML you persist from an editable document (XSS risk).
  • For one editable box, prefer contenteditable.
  • Related: defaultView, customElementRegistry, Document constructor.

Universal Browser Support

Document.designMode is a long-standing HTML Document property (on / off). Logos use the shared browser-image-sprite.png sprite from this project. Check MDN for historical value quirks.

Widely available · Standard

Document.designMode

Read/write string — "on" or "off" — controlling whether the entire document is editable.

Universal Widely available
Google Chrome Full support · Default off since Chrome 43
Full support
Mozilla Firefox Full support · Spec default off
Full support
Apple Safari Full support · macOS & iOS
Full support
Microsoft Edge Full support · Chromium
Full support
Opera Full support · Modern versions
Full support
Internet Explorer Supported (legacy capitalization quirks)
Full support
Document.designMode Excellent

Bottom line: Use designMode for whole-document (often iframe) editing. Prefer contenteditable for scoped UI editors, and always sanitize saved HTML.

Conclusion

Document.designMode turns whole-document editing on or off. It shines in classic iframe editors; for a single rich-text box, use contenteditable instead, and always treat user HTML carefully.

Continue with dir, defaultView, currentScript, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use lowercase "on" / "off"
  • Enable designMode on iframe documents for editors
  • Wait for iframe load before setting the property
  • Sanitize HTML before saving to a server
  • Prefer contenteditable for scoped UI

❌ Don’t

  • Leave the main site chrome editable in production
  • Rely on legacy "inherit" values
  • Trust unsanitized HTML from an editable document
  • Forget same-origin limits on contentDocument
  • Use designMode when a plain <textarea> is enough

Key Takeaways

Knowledge Unlocked

Five things to remember about document.designMode

Whole-document editing switch — on or off.

5
Core concepts
02

Default

"off"

Spec
🔒03

Access

get + set

DOM
🎨04

Classic

iframe editor

MDN
📝05

Modern

contenteditable

Scoped

❓ Frequently Asked Questions

It controls whether the entire document is editable. Set it to "on" to allow editing the whole page (or iframe document), or "off" to turn editing off.
No. MDN does not mark Document.designMode as Deprecated, Experimental, or Non-standard. It remains a standard HTML Document property. Prefer contenteditable when you only need a single element editable.
According to MDN and the specification, valid values are the strings "on" and "off". The property is meant to default to "off".
MDN example: iframeNode.contentDocument.designMode = "on". That turns the iframe's document into an editable surface (classic rich-text pattern).
designMode edits the whole document. contenteditable (or contentEditable) makes one element or subtree editable — usually the better choice for modern UI editors.
Yes. MDN notes earlier Chrome/IE used "inherit", and IE6–10 capitalized values. Modern Chrome (43+) defaults to "off" and no longer supports "inherit".
Did you know?

Many early online rich-text editors were literally an empty iframe with designMode = "on" plus toolbar buttons calling document.execCommand(...). That stack still works in many browsers, but modern apps often use contenteditable or dedicated editor libraries instead.

Next: dir

Learn how to read and set document text direction (ltr / rtl).

dir →

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.

6 people found this page helpful