JavaScript fontsize()Method
JavaScript String Object
Definition and Usage
The fontsize() method is used to display a string in a specified size.
This method returns the string wrapped in a <font> tag, as follows:
<font size="size">string</font>
Syntax
string.fontsize(size)
| Parameter | Description |
|---|---|
| size | Required. The size parameter must be a number from 1 to 7. |
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the fontsize() method.
Examples
Examples
Display a string using a specified size:
<script>
var str = "Hello world!";
document.write(str.fontsize(7));
</script>
var str = "Hello world!";
document.write(str.fontsize(7));
</script>
Try it Yourself »
JavaScript String Object Other Extensions