javascripteditorexeccommand

document.execCommand() FontSize in pixels?


How can I change font size to 30px (for example) using document.execCommand?

This:

document.execCommand("fontSize", false, "30px");

doesn't work, because in 3rd argument of the function execCommand, it only allows me to input a value between and including 1 to 7.


Solution

  • It's a limitation of the FontSize command. There are various options I can think of: