<?xml version="1.0" encoding='utf-8'?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="Canvas element - Page 5 - Wikipedia">
<p>
<a accesskey="1" href="page.php?w=Canvas_element&amp;p=4">1.Previous</a><br />
<a accesskey="3" href="page.php?w=Canvas_element&amp;p=6">3.Next</a>
</p>
<p>determines whether to use the canvas API, <a href="page.php?w=WebGL">WebGL</a>, or WebGL2 <a href="page.php?w=Rendering_%28computer_graphics%29">rendering</a> context.</p>

<p><big> Example </big></p>
<p>The following code creates a  element in an HTML page:<syntaxhighlight lang=html><canvas id="example" width="200" height="200">This text is displayed if your browser does not support HTML canvas element.</canvas></syntaxhighlight></p>

<p>Using <a href="page.php?w=JavaScript">JavaScript</a>, you can draw on the canvas:<syntaxhighlight lang="javascript">var example = document.getElementById('example');var context = example.getContext('2d');context.fillStyle = 'red';context.fillRect(30, 30, 50, 50);</syntaxhighlight></p><p>
<a accesskey="1" href="page.php?w=Canvas_element&amp;p=4">1.Previous</a><br />
<a accesskey="3" href="page.php?w=Canvas_element&amp;p=6">3.Next</a>
</p>

<do type="prev" label="Search">
        <go href="search.wml"/>
</do>

</card>
</wml>
