Search w3schools.com:

SHARE THIS PAGE

JavaScript sub() Method

String Object Reference JavaScript String Object

Definition and Usage

The sub() method is used to display a string as subscript text.

This method returns the string embedded in the <sub> tag, like this:

<sub>string</sub>

Syntax

string.sub()


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The sub() method is supported in all major browsers.


Example

Example

Display string as subscript text:

<script>

var str = "Hello world!";
document.write(str.sub());

</script>

Try it yourself »


String Object Reference JavaScript String Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]