Newly availableNewly available. Verify your target environments before adopting.

Overview

The contenteditable="plaintext-only" global HTML attribute allows the user to edit the content of an element, but prevents rich-text formatting.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
api.HTMLElement.contentEditable.plaintext-only
51
12
136
5.1
51
5
html.global_attributes.contenteditable.plaintext-only

`contenteditable="plaintext-only"`

51
12
136
5
51
4.2
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)

Syntax

HTML
<div contenteditable="plaintext-only"
  style="border:1px solid #ccc; padding:0.5rem; min-height:3rem;">
  Only plain text can be edited here
</div>

Live demo

pre-ntext. only. edit

richtextinput prevention. with contenteditable=plaintext-only

PreviewFullscreen

Notes styleedeita

shinpl textedeita create. with plaintext-only

PreviewFullscreen

True and plaintext-only. Difference

richtextallowallow and pre-ntextforced. behaviorcomparison.

PreviewFullscreen

Use cases

  • Using contenteditable="plaintext-only"

    The contenteditable="plaintext-only" global HTML attribute allows the user to edit the content of an element, but prevents rich-text formatting.

Cautions

  • May not be supported in older browsers.

Accessibility

  • Verify how this element is announced by screen readers.

Powered by web-features