HTML5 Canvas Tag

HTML5 has made it very easy to draw graphics on a web page with the help of Javascript. Canvas is actually used as a container of a graphic which has not border and no content in it. Actual graphic is written using Javascript. Now you can not only draw simple graphics but can render game graphics, photo compositions, other visual images on the fly. You can give various effects like coloring, multicoloring figures or text, gradiant etc with the use of canvas.

The HTML5 <canvas> Tag has many attributes like width, height, style, class, id and name which you can use as and when required.

Syntax

Browser Support

Almost all latest browsers like Safari, Google Chrome, Mozilla Firefox, Opera, Internet Explorer 9.0 support many HTML5 features and functionalities. The good thing is that now many mobiles web browsers like iPhones, iPads, and Android phones all have excellent support for HTML5.

Canvas Border

The <style> attribute is used to create a border of canvas.

Canvas Border Example

This will produce following result

Canvas Circle

The ctx.arc() function is used to create circles based on a center points and a radius.

Canvas Circle Example

This will produce following result