JavaScript fontcolor() Method
JavaScript String object
Definition and Usage
The fontcolor() method is used to display a string in a specified color.
This method returns the string with an tag added, as shown below:
string
Syntax
string
.fontcolor(color)
| Parameters | Description |
|---|---|
| color | Required. Specifies the font-color for the string. The value must be a color name (red), an RGB value (rgb(255,0,0)), or a hexadecimal number (#FF0000). |
Browser support





All major browsers support the fontcolor() method.
Example
Example
Display the string in green:
Try it »
JavaScript String object