Met Canvas Stroketext
# HTML canvas strokeText() Method
[ Canvas Object](#)
## Example
Using strokeText() to write the text "Hello world!" and "Big smile!" (with gradient) on the canvas:
YourbrowserdoesnotsupporttheHTML5canvastag.
JavaScript:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.font="20px Georgia";
ctx.strokeText("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.strokeStyle=gradient;
ctx.strokeText("Big smile!",10,90);
[Try it Β»](#)
* * *
## Browser Support

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