JavaScript sub()Method
JavaScript String Object
Definition and Usage
The sub() method is used to display a string as subscript.
This method returns the string with the <sub> tag added, as shown below:
<sub>string</sub>
Syntax
string.sub()
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the sub() method.
Example
Example
Display a string as subscript:
<script>
var str = "Hello world!";
document.write(str.sub());
</script>
var str = "Hello world!";
document.write(str.sub());
</script>
Try it yourself »
JavaScript String Object Other Extensions