Easy Tutorial
❮ Jsref Source Regexp Met Text Blur ❯

HTML canvas strokeText() Method

Canvas Object

Example

Use strokeText() to write the text "Hello world!" and "Big smile!" (with gradient) on the canvas:

JavaScript:


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 <canvas> element.

Note: Safari does not support the maxWidth parameter.


Definition and Usage

The strokeText() method draws text on the canvas (no fill). The default color of the text is black.

Tip: Use the font property to define font and font size, and use the strokeStyle property to render the text in another 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 where to start drawing the text (relative to the canvas).
y The y coordinate where to start drawing the text (relative to the canvas).
maxWidth Optional. The maximum allowed width of the text, in pixels.

Canvas Object

❮ Jsref Source Regexp Met Text Blur ❯