Easy Tutorial
❮ Att Iframe Scrolling Att Object Border ❯

HTML canvas fillText() Method

HTML canvas Reference Manual

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 the font and font size, and use the fillStyle property to render the text in another 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 width of the text, in pixels.

❮ Att Iframe Scrolling Att Object Border ❯