Met Canvas Filltext
# HTML canvas fillText() Method
[ Canvas Object](#)
## Example
Use fillText() to write the text "Hello world!" and "Big smile!" on the canvas:
YourbrowserdoesnotsupporttheHTML5canvastag.
JavaScript:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.font="20px Georgia";
ctx.fillText("Hello World!",10,50);
ctx.font="30px Verdana";
// Create gradient
var gradient=ctx.createLinearGradient(0,0,c.width,0);
gradient.addColorStop("0","magenta");
gradient.addColorStop("0.5","blue");
gradient.addColorStop("1.0","red");
// Fill with gradient
ctx.fillStyle=gradient;
ctx.fillText("Big smile!",10,90);
[Try it Β»](#)
* * *
## Browser Support

The fillText() method is supported in Internet Explorer 9, Firefox, Opera, Chrome, and Safari.
**Note:** Internet Explorer 8 and earlier versions do not support the element.
**Note:** Safari does not support the maxWidth parameter.
* * *
## Definition and Usage
The fillText() method draws filled text on the canvas. The default color of the text is black.
**Tip:** Use the (#) property to define the font and font size, and use the (#) property to render the text in a different color or gradient.
| JavaScript syntax: | _context_.fillText(_text,x,y,maxWidth_); |
| --- |
## Parameter Values
| Parameter | Description |
| --- | --- |
| _text_ | The text to be output on the canvas. |
| _x_ | The x coordinate position where the text drawing starts (relative to the canvas). |
| _y_ | The y coordinate position where the text drawing starts (relative to the canvas). |
| _maxWidth_ | Optional. The maximum allowed text width, in pixels. |
* * Canvas Object](#)
YouTip