contenteditable="plaintext-only"
contenteditable="plaintext-only" は要素のコンテンツ編集をプレーンテキストに限定し、書式付きテキストの貼り付けを防止します。
対応ブラウザ
| 機能 | デスクトップ | モバイル | ||||
|---|---|---|---|---|---|---|
| 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="プレーンテキストのみ"`。 | 51 | 12 | 136 | 5 | 51 | 4.2 |
基本構文
HTML
<div contenteditable="plaintext-only"
style="border:1px solid #ccc; padding:0.5rem; min-height:3rem;">
Only plain text can be edited here
</div> ライブデモ
True and plaintext-only. Difference
richtextallowallow and pre-ntextforced. behaviorcomparison.
プレビュー全画面表示
実務での使いどころ
-
contenteditable="plaintext-only" の活用
contenteditable=plaintext-only。プレーンテキストのみの編集モード。
注意点
- 古いブラウザでは対応していない場合がある。
アクセシビリティ
- スクリーンリーダーでの読み上げを確認すること。