Create a Subscript Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Subscript


You can create a <sub> element by using the document.createElement() method:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button onclick="myFunction()">create a SUB element with some text</button>

function myFunction() {/* w w  w . j av  a2  s. c om*/
    var x = document.createElement("SUB");
    var t = document.createTextNode("This text contains subscript text");


Related Tutorials