Easy Tutorial
❮ Prop Param Name Prop Meter High ❯

HTML canvas fillText() Method

Canvas Object

Example

Using fillText(), write the text "Hello world!" and "Big smile!" on the canvas:

JavaScript:


Browser Support

Internet Explorer 9, Firefox, Opera, Chrome, and Safari support the fillText() 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 fillText() method draws filled text on the canvas. The default color of the text is black.

Tip: Use the font property to define font and font size, and use the fillStyle property to render the text with a different color/gradient.

| JavaScript Syntax: | context.fillText(text, x, y, maxWidth); | | --- | --- |

Parameter Values

Parameter Description
text Specifies the text to be output on the canvas.
x The x coordinate where the text starts (relative to the canvas).
y The y coordinate where the text starts (relative to the canvas).
maxWidth Optional. The maximum allowed text width in pixels.

Canvas Object

❮ Prop Param Name Prop Meter High ❯