HTML <canvas> title Attribute

The title attribute on a <canvas> tag adds a tooltip with title text to the canvas element.

Hovering the mouse over the canvas will display the tooltip.



A title attribute on a <canvas> element.
Hover over the canvas to see the tooltip.

<canvas title="This is a nice&#10blue canvas."
        id="mycanvas" width="120" height="120">


   ( () => {

    let canvas = document.getElementById("mycanvas");
    let context = canvas.getContext("2d");

    context.fillStyle = "lightblue";
    context.fillRect(10, 10, 100, 100);

  } )();


Code explanation

  • The title attribute is placed in the <canvas> opening tag.
  • The value can be any string.
  • Hover the cursor over the canvas and after a second the tooltip appears.

Using title

The title attributes provides additional information about the <canvas> element.

The title value can be seen as tooltip text.

Tooltips are shown when the canvas element is hovered.


<canvas title="value" >



Value Description
value A string value. A title can span multiple lines by including newline or carriage-return characters:  &#10;  or  &#013;.

Browser support

Here is when title support started for each browser:

4.0 Jan 2010
2.0 Oct 2006
9.0 Mar 2011
9.0 Jun 2006
3.1 Mar 2008

You may also like

 Back to <canvas>

Author: Jack Poorte
Published: Jun 20 2021
Last Reviewed: Sep 30 2023

What's your favorite/least favorite part of Dofactory?