JavaScript > Methods

Subscript style in JavaScript

How to apply subscript style to the text in JavaScript?


In case we want to apply the subscript style to the text in the html page, we can use this approach.

<script>
        document.write("This is Subscript text ");
        document.write(" This is Subscript text".sub());
</script>

In the above code snippet, we have written “This is Subscript text” in both document.write lines but in the 2nd statement we have called the sub() method using the text that makes this text in subscript style as you can see in the below picture.

OUTPUT

 Views: 4767 | Post Order: 48



Write for us






Hosting Recommendations