Formatting

suggest change

Users can add formatting to contenteditable documents or elements using their browser’s features, such as common keyboard shortcuts for formatting (Ctrl-B for bold, Ctrl-I for italic, etc.) or by dragging and dropping images, links, or markup from the clipboard.

document.execCommand is deprecated and browser-only. It changes the current selection, so a call with no selection does nothing useful. Ctrl-B is a Windows and Linux shortcut. macOS uses Cmd-B.

document.execCommand('bold', false, null); // toggles bold formatting
document.execCommand('italic', false, null); // toggles italic formatting
document.execCommand('underline', false, null); // toggles underline

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents