JavaScript fontsize()Method

String 对象参考手册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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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>

Try it Yourself »


String 对象参考手册JavaScript String Object Other Extensions