HTML DOM Document execCommand()

Example

Make the selected text bold:

document.execCommand("bold");
Try it Yourself »

Description

The execCommand() method is deprecated. Do NOT use it.

The applets property returns an empty HTMLCollection in all new browsers.

The <applet> element is not supported in HTML5.


Syntax

document.execCommand(command, showUI, value)

Parameters

Parameter Description
command The name of the command to execute:

"backColor"
"bold"
"createLink"
"copy"
"cut"
"defaultParagraphSeparator"
"delete"
"fontName"
"fontSize"
"foreColor"
"formatBlock"
"forwardDelete"
"insertHorizontalRule"
"insertHTML"
"insertImage"
"insertLineBreak"
"insertOrderedList"
"insertParagraph"
"insertText"
"insertUnorderedList"
"justifyCenter"
"justifyFull"
"justifyLeft"
"justifyRight"
"outdent"
"paste"
"redo"
"selectAll"
"strikethrough"
"styleWithCss"
"subscript"
"superscript"
"undo"
"unlink"
"useCSS"
showUI A Boolean.
Specifies if the UI should be shown or not.
value Some commands need a value to be completed.

Return Value

Type Description
Booleantrue if the command is supported, otherwise false.

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.