.1 200 OK date: Thu, 02 Jul 2026 02:29:21 GMT server: mw-web.codfw.main-77cfb8ddf-hkllx x-content-type-options: nosniff content-language: en accept-ch: reporting-endpoints: csp-report-to-endpoint='/w/api.php?action=cspreport&format=json'; content-security-policy: script-src 'unsafe-eval' blob: 'self' meta.wikimedia.org *.wikimedia.org *.wikipedia.org *.wikinews.org *.wiktionary.org *.wikibooks.org *.wikiversity.org *.wikisource.org wikisource.org *.wikiquote.org *.wikidata.org *.wikifunctions.org *.wikivoyage.org *.mediawiki.org mediawiki.org wikimedia.org *.wmflabs.org *.wmcloud.org *.toolforge.org wss://*.toolforge.org *.jsdelivr.net unpkg.com cdnjs.cloudflare.com raw.githubusercontent.com *.github.com code.jquery.com cdn.mathjax.org use.typekit.net fonts.cdnfonts.com use.fontawesome.com i.ytimg.com rsms.me doi.org localhost https://localhost:* http://localhost:* wss://localhost:* ws://localhost:* *.google.com *.gstatic.com *.googleapis.com *.translate.yandex.net yastatic.net ya.ru radically.github.io cdn.sammdot.ca cdn.fontshare.com viaf.org publicai-proxy.alaexis.workers.dev iiif.archive.org api.flickr.com live.staticflickr.com api.anthropic.com api.openai.com api.publicai.co catalogo.pusc.it parsifal.urbe.it opac.sbn.it overpass-api.de api.openrouteservice.org archive.org *.openstreetmap.org *.waymarkedtrails.org *.thunderforest.com registry.ipe.wiki analytics.ipe.wiki qlever.dev app.goacoustic.com wikipedia-archive.ourworldindata.org api.inaturalist.org inaturalist-open-data.s3.amazonaws.com validator.w3.org db.onlinewebfonts.com fontlibrary.org 'unsafe-inline' auth.wikimedia.org; default-src 'self' data: blob: upload.wikimedia.org https://commons.wikimedia.org meta.wikimedia.org *.wikimedia.org *.wikipedia.org *.wikinews.org *.wiktionary.org *.wikibooks.org *.wikiversity.org *.wikisource.org wikisource.org *.wikiquote.org *.wikidata.org *.wikifunctions.org *.wikivoyage.org *.mediawiki.org mediawiki.org wikimedia.org *.wmflabs.org *.wmcloud.org *.toolforge.org wss://*.toolforge.org *.jsdelivr.net unpkg.com cdnjs.cloudflare.com raw.githubusercontent.com *.github.com code.jquery.com cdn.mathjax.org use.typekit.net fonts.cdnfonts.com use.fontawesome.com i.ytimg.com rsms.me doi.org localhost https://localhost:* http://localhost:* wss://localhost:* ws://localhost:* *.google.com *.gstatic.com *.googleapis.com *.translate.yandex.net yastatic.net ya.ru radically.github.io cdn.sammdot.ca cdn.fontshare.com viaf.org publicai-proxy.alaexis.workers.dev iiif.archive.org api.flickr.com live.staticflickr.com api.anthropic.com api.openai.com api.publicai.co catalogo.pusc.it parsifal.urbe.it opac.sbn.it overpass-api.de api.openrouteservice.org archive.org *.openstreetmap.org *.waymarkedtrails.org *.thunderforest.com registry.ipe.wiki analytics.ipe.wiki qlever.dev app.goacoustic.com wikipedia-archive.ourworldindata.org api.inaturalist.org inaturalist-open-data.s3.amazonaws.com validator.w3.org db.onlinewebfonts.com fontlibrary.org en.wikibooks.org en.wikinews.org en.wikiquote.org en.wikisource.org en.wikiversity.org en.wikivoyage.org en.wiktionary.org www.mediawiki.org commons.wikimedia.org foundation.wikimedia.org incubator.wikimedia.org species.wikimedia.org wikimania.wikimedia.org www.wikidata.org www.wikifunctions.org auth.wikimedia.org; style-src 'self' data: blob: upload.wikimedia.org https://commons.wikimedia.org meta.wikimedia.org *.wikimedia.org *.wikipedia.org *.wikinews.org *.wiktionary.org *.wikibooks.org *.wikiversity.org *.wikisource.org wikisource.org *.wikiquote.org *.wikidata.org *.wikifunctions.org *.wikivoyage.org *.mediawiki.org mediawiki.org wikimedia.org *.wmflabs.org *.wmcloud.org *.toolforge.org wss://*.toolforge.org *.jsdelivr.net unpkg.com cdnjs.cloudflare.com raw.githubusercontent.com *.github.com code.jquery.com cdn.mathjax.org use.typekit.net fonts.cdnfonts.com use.fontawesome.com i.ytimg.com rsms.me doi.org localhost https://localhost:* http://localhost:* wss://localhost:* ws://localhost:* *.google.com *.gstatic.com *.googleapis.com *.translate.yandex.net yastatic.net ya.ru radically.github.io cdn.sammdot.ca cdn.fontshare.com viaf.org publicai-proxy.alaexis.workers.dev iiif.archive.org api.flickr.com live.staticflickr.com api.anthropic.com api.openai.com api.publicai.co catalogo.pusc.it parsifal.urbe.it opac.sbn.it overpass-api.de api.openrouteservice.org archive.org *.openstreetmap.org *.waymarkedtrails.org *.thunderforest.com registry.ipe.wiki analytics.ipe.wiki qlever.dev app.goacoustic.com wikipedia-archive.ourworldindata.org api.inaturalist.org inaturalist-open-data.s3.amazonaws.com validator.w3.org db.onlinewebfonts.com fontlibrary.org 'unsafe-inline'; object-src 'none'; report-uri /w/api.php?action=cspreport&format=json; report-to csp-report-to-endpoint last-modified: Thu, 18 Jun 2026 02:29:21 GMT content-type: text/html; charset=UTF-8 age: 0 accept-ranges: bytes x-cache: cp2047 miss, cp2047 miss x-cache-status: miss server-timing: cache;desc="miss", host;desc="cp2047" strict-transport-security: max-age=106384710; includeSubDomains; preload report-to: { "group": "wm_nel", "max_age": 604800, "endpoints": [{ "url": "https://intake-logging.wikimedia.org/v1/events?stream=w3c.reportingapi.network_error&schema_uri=/w3c/reportingapi/network_error/1.0.0" }] } nel: { "report_to": "wm_nel", "max_age": 604800, "failure_fraction": 0.05, "success_fraction": 0.0} set-cookie: WMF-Last-Access=02-Jul-2026;Path=/;HttpOnly;secure;Expires=Mon, 03 Aug 2026 00:00:00 GMT set-cookie: WMF-Last-Access-Global=02-Jul-2026;Path=/;Domain=.wikipedia.org;HttpOnly;secure;Expires=Mon, 03 Aug 2026 00:00:00 GMT set-cookie: WMF-DP=ad2;Path=/;HttpOnly;secure;Expires=Thu, 02 Jul 2026 00:00:00 GMT x-client-ip: 75.28.18.94 cache-control: private, s-maxage=0, max-age=0, must-revalidate, no-transform vary: Accept-Encoding,X-Subdomain,Cookie,Authorization,User-Agent set-cookie: GeoIP=US:TX:McKinney:33.20:-96.62:v4; Path=/; secure; Domain=.wikipedia.org set-cookie: NetworkProbeLimit=0.001;Path=/;Secure;SameSite=None;Max-Age=3600 set-cookie: WMF-Uniq=IqNrwHgQ7g22evlQTClvCAORAAAAAFvdGlrWBlF1RGofIV22z_pbIEbHvWHYqMfA;Domain=.wikipedia.org;Path=/;HttpOnly;secure;SameSite=None;Expires=Fri, 02 Jul 2027 00:00:00 GMT transfer-encoding: chunked x-request-id: 7b9d4016-dd64-42ef-8e2e-b45851fb0259 x-analytics: 8000 Canvas element - Wikipedia Jump to content Main menu Main menu move to sidebar hide Navigation Main page Contents Current events Random article About Wikipedia Contact us Contribute Help Learn to edit Community portal Recent changes Upload file Special pages Search Search Appearance Donate Create account Log in Personal tools Donate Create account Log in Contents move to sidebar hide (Top) 1 History 2 Usage 3 Example 4 Canvas element size versus drawing surface size 5 Canvas versus Scalable Vector Graphics (SVG) 6 Reactions Toggle Reactions subsection 6.1 Intellectual property over canvas 6.2 Privacy concerns 7 Browser support 8 See also 9 References 10 External links Toggle the table of contents Canvas element 22 languages العربية Български বাংলা Čeština Deutsch Español فارسی Suomi Français Magyar Bahasa Indonesia Italiano 日本語 한국어 Latviešu Polski Português Русский Српски / srpski Українська Tiếng Việt 中文 Edit links Article Talk English Read Edit View history Tools Tools move to sidebar hide Actions Read Edit View history General What links here Related changes Upload file Permanent link Page information Cite this page Get shortened URL Switch to legacy parser Print/export Download as PDF Printable version In other projects Wikibooks Wikidata item Appearance move to sidebar hide From Wikipedia, the free encyclopedia HTML element This article is about the HTML element. For the general element in user interfaces, see Canvas (GUI) . HTML HTML and variants Dynamic HTML HTML5 XHTML Basic Mobile Profile HTML elements and attributes HTML element article audio blink canvas div and span marquee meta video HTML attribute alt attribute HTML frame Editing HTML editor Text editor Character encodings and language Character encodings Character entity references (named characters) Unicode Language code Document and browser models Document Object Model Browser Object Model Style sheets CSS Font family Web colors Client-side scripting and APIs JavaScript WebCL HTMX Graphics and Web3D technology Web3D WebGL WebGPU WebXR W3C Validator WHATWG Quirks mode Web storage Rendering engine Comparisons Document markup languages Comparison of browser engines v t e The HTML canvas element allows for dynamic, scriptable rendering of 2D shapes and bitmap images. Introduced in HTML5 , it is a low level, procedural model that updates a bitmap . The < canvas > element also helps in making 2D games . While the < canvas > element offers its own 2D drawing API , it also supports the WebGL API to allow 3D rendering with OpenGL ES . History [ edit ] Canvas was initially introduced by Apple for use in their own Mac OS X WebKit component in 2004, [ 1 ] powering applications like Dashboard widgets and the Safari browser. Later, in 2005, it was adopted in version 1.8 of Gecko browsers, [ 2 ] and Opera in 2006, [ 3 ] and standardized by the Web Hypertext Application Technology Working Group (WHATWG) on new proposed specifications for next generation web technologies. [ 4 ] Usage [ edit ] A canvas consists of a drawable region defined in HTML code with height and width attributes. JavaScript code may access the area through a full set of drawing functions similar to those of other common 2D APIs , thus allowing for dynamically generated graphics. Some anticipated uses of canvas include building graphs, animations , games, and image composition. Interacting with the canvas involves obtaining the canvas' rendering context, which determines whether to use the canvas API, WebGL , or WebGL2 rendering context. Example [ edit ] The following code creates a < canvas > element in an HTML page: \nThis text is displayed if your browser does not support HTML canvas element.\n</canvas>\n"}}'> < canvas id = "example" width = "200" height = "200" > This text is displayed if your browser does not support HTML canvas element. </ canvas > Using JavaScript , you can draw on the canvas: var example = document . getElementById ( 'example' ); var context = example . getContext ( '2d' ); context . fillStyle = 'red' ; context . fillRect ( 30 , 30 , 50 , 50 ); This code draws a red rectangle on the screen. The Canvas API also provides save() and restore() , for saving and restoring all the canvas context's attributes. Canvas element size versus drawing surface size [ edit ] A canvas actually has two sizes: the size of the element itself and the size of the element's drawing surface. Setting the element's width and height attributes sets both of these sizes; CSS attributes affect only the element's size and not the drawing surface. By default, both the canvas element's size and the size of its drawing surface is 300 screen pixels wide and 150 screen pixels high. In the listing shown in the example, which uses CSS to set the canvas element's size, the size of the element is 600 pixels wide and 300 pixels high, but the size of the drawing surface remains unchanged at the default value of 300 pixels × 150 pixels. When a canvas element's size does not match the size of its drawing surface, the browser scales the drawing surface to fit the element (which may result in surprising and unwanted effects). Example setting element size and drawing surface size to different values: \n<html>\n <head>\n <title>Canvas element size: 600 x 300,\n Canvas drawing surface size: 300 x 150</title>\n <style>\n body {\n background: #dddddd;\n }\n #canvas {\n margin: 20px;\n padding: 20px;\n background: #ffffff;\n border: thin inset #aaaaaa;\n width: 600px;\n height: 300px;\n }\n </style>\n </head>\n <body>\n <canvas id=\"canvas\">\n Canvas not supported\n </canvas>\n </body>\n</html>\n"}}'> <!DOCTYPE html> < html > < head > < title > Canvas element size: 600 x 300, Canvas drawing surface size: 300 x 150 </ title > < style > body { background : #dddddd ; } # canvas { margin : 20 px ; padding : 20 px ; background : #ffffff ; border : thin inset #aaaaaa ; width : 600 px ; height : 300 px ; } </ style > </ head > < body > < canvas id = "canvas" > Canvas not supported </ canvas > </ body > </ html > Canvas versus Scalable Vector Graphics (SVG) [ edit ] SVG is an alternative approach to drawing shapes in browsers. [ 5 ] Unlike canvas, which is raster -based, SVG is vector -based, so that each drawn shape is remembered as an object in a scene graph or Document Object Model , which is subsequently rendered to a bitmap . This means that if attributes of an SVG object are changed, the browser can automatically re-render the scene. Canvas objects, on the other hand, are drawn in immediate mode . In the canvas example above, the rectangle draw operation modifies the canvas, and its representation as a rectangle is forgotten by the system. If the rectangle's position were to be changed, the canvas would need to be redrawn, including any objects that might have been covered by the rectangle. In the equivalent SVG case, one could simply change the position attributes of the rectangle and the browser would determine how to repaint it. There are additional JavaScript libraries that abstract the canvas model to have svg-like scene capabilities within the canvas element. Multiple canvas layers can also be used, meaning that only specific layers need to be recreated when changes are required. SVG images are represented in XML , and complex scenes can be created and maintained with XML editing tools. The SVG scene graph enables event handlers to be associated with objects, so a rectangle may respond to an onClick event. To get the same functionality with canvas, one must manually match the coordinates of the mouse click with the coordinates of the drawn rectangle to determine whether it was clicked. Conceptually, canvas is a lower-level API upon which higher-level interfaces might be built (for example, SVG support). There are JavaScript libraries that provide partial SVG implementations using canvas for browsers that do not provide SVG but support canvas, such as the browsers in Android 2.x. However, this is not normally the case—they are independent standards. The situation is complicated because there are scene graph libraries for canvas, and SVG has some bitmap manipulation functionality. Reactions [ edit ] At the time of its introduction, the canvas element was met with mixed reactions from the web standards community. There have been arguments against Apple's decision to create a new proprietary element instead of supporting the SVG standard. There are other concerns about syntax, such as the absence of a namespace . [ 6 ] Intellectual property over canvas [ edit ] On March 14, 2007, WebKit developer Dave Hyatt forwarded an email from Apple's Senior Patent Counsel, Helene Plotka Workman, [ 7 ] which stated that Apple reserved all intellectual property rights relative to WHATWG's Web Applications 1.0 Working Draft, dated March 24, 2005, Section 10.1, entitled "Graphics: The bitmap canvas", [ 8 ] but left the door open to licensing the patents should the specification be transferred to a standards body with a formal patent policy . This caused considerable discussion among web developers and raised questions concerning the WHATWG's lack of a policy on patents in comparison to the World Wide Web Consortium (W3C)'s explicit favoring of royalty-free licenses. Apple later disclosed the patents under the W3C's royalty-free patent licensing terms. [ 9 ] The disclosure means that Apple is required to provide royalty-free licensing for the patent whenever the Canvas element becomes part of a future W3C recommendation created by the HTML working group. [ 10 ] Privacy concerns [ edit ] Canvas fingerprinting is one of a number of browser fingerprinting techniques for tracking online users that allow websites to identify and track visitors using the HTML < canvas > element. The technique received wide media coverage in 2014, [ 11 ] [ 12 ] [ 13 ] [ 14 ] after researchers from Princeton University and KU Leuven University described it in their paper The Web never forgets . [ 15 ] The privacy concerns regarding canvas fingerprinting center around the fact that even deleting cookies and clearing the cache will not be sufficient for users to avoid online tracking. Browser support [ edit ] The element is supported by the current versions of Mozilla Firefox , Google Chrome , Internet Explorer , Safari , Konqueror , Opera [ 16 ] and Microsoft Edge . [ 17 ] See also [ edit ] Anti-Grain Geometry (AGG) Cairo (graphics) Display PostScript Graphics Device Interface (GDI+) Quartz 2D WebGL References [ edit ] ↑ Ian Hixie (2004-07-12). "Extending HTML" . Retrieved 2011-06-13 . ↑ Mozilla Developer Connection. "HTMLCanvasElement" . Archived from the original on 2011-06-04 . Retrieved 2011-06-13 . ↑ "Opera 9.0 changelog" . Retrieved 2006-06-20 . {{ cite web }} : CS1 maint: deprecated archival service ( link ) ↑ "HTML Standard" . html.spec.whatwg.org . Retrieved 2025-02-09 . ↑ "Scalable Vector Graphics | CorelDRAW" . www.coreldraw.com . Retrieved 2022-09-23 . ↑ Ian Hickson remarks regarding canvas and other Apple extensions to HTML ↑ &#91;whatwg&#93;</nowiki> Web Applications 1.0 Draft, David Hyatt, Wed Mar 14 14:31:53 PDT 2007"},"access-date":{"wt":"2007-05-01"},"archive-url":{"wt":"https://web.archive.org/web/20070502083225/http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2007-March/010129.html"},"archive-date":{"wt":"2007-05-02"},"url-status":{"wt":"dead"}},"i":0}}]}'/> "[whatwg] Web Applications 1.0 Draft, David Hyatt, Wed Mar 14 14:31:53 PDT 2007" . Archived from the original on 2007-05-02 . Retrieved 2007-05-01 . ↑ Web Applications 1.0 Early Working Draft - Dynamic graphics: The bitmap canvas ↑ HTML Working Group Patent Policy Status – Known Disclosures ↑ W3C patent policy in use by HTML working group ↑ Knibbs, Kate (July 21, 2014). "What You Need to Know About the Sneakiest New Online Tracking Tool" . Gizmodo . Retrieved July 21, 2014 . ↑ Joseph Steinberg (July 23, 2014). "You Are Being Tracked Online By A Sneaky New Technology -- Here's What You Need To Know" . Forbes . Retrieved November 15, 2014 . ↑ Angwin, Julia (July 21, 2014). "Meet the Online Tracking Device That is Virtually Impossible to Block" . ProPublica . Retrieved July 21, 2014 . ↑ Kirk, Jeremy (July 21, 2014). "Stealthy Web tracking tools pose increasing privacy risks to users" . PC World . Retrieved July 21, 2014 . ↑ Acar, Gunes; Eubank, Christian; Englehardt, Steven; Juarez, Marc; Narayanan, Arvind; Diaz, Claudia (July 24, 2014). "The Web never forgets: Persistent tracking mechanisms in the wild" . Retrieved July 24, 2014 . ↑ Sucan, Mihai (4 Feb 2010). "SVG or Canvas? Choosing between the two" . Opera Software . Archived from the original on 23 June 2010 . Retrieved 3 May 2010 . ↑ "Canvas, Microsoft Edge documentation" . External links [ edit ] canvas</code> element"},"publisher":{"wt":"[[World Wide Web Consortium|W3C]]"},"date":{"wt":"2014-10-28"},"access-date":{"wt":"2015-01-09"}},"i":0}}]}'/> The canvas element , W3C , 2014-10-28 , retrieved 2015-01-09 HTML Canvas 2D Context , W3C , 2014-08-21 , retrieved 2015-01-09 Canvas description in WHATWG Web Applications draft specifications Canvas reference page in Apple Developers Connection Basic Canvas Tutorial on Opera Developer Community Canvas tutorial and introductory page on Mozilla Developer center Archived 2012-08-03 at the Wayback Machine v t e Web interfaces Server-side Protocols HTTP v2 v3 Encryption WebDAV CGI SCGI FCGI AJP WSRP WebSocket Server APIs C NSAPI C ASAPI C ISAPI COM ASP Jakarta Servlet container CLI OWIN ASP.NET Handler Python WSGI Python ASGI Ruby Rack JavaScript JSGI Perl PSGI Portlet container Apache modules mod_include mod_jk mod_lisp mod_mono mod_parrot mod_perl mod_php mod_proxy mod_python mod_wsgi mod_ruby Phusion Passenger Topics Web service vs. Web resource WOA vs. ROA Open API Webhook Application server comparison Scripting Client-side Browser APIs C NPAPI LiveConnect XPConnect C NPRuntime C PPAPI NaCl ActiveX BHO XBAP Web APIs WHATWG Audio Canvas DOM SSE Video WebSockets Web messaging Web storage Web worker XMLHttpRequest W3C DOM events EME File Geolocation IndexedDB MSE SVG WebAssembly WebAuthn WebGPU WebRTC WebXR Khronos WebCL WebGL Others Gears Web SQL Database (formerly W3C) WebUSB Topics Ajax and Remote scripting vs. DHTML Browser extension Cross-site scripting and CORS Hydration Mashup Persistent data Web IDL Scripting Related topics Frontend and backend Microservices REST GraphQL Push technology Solution stack Web page Static Dynamic Web standards Web API security Web application Rich Single-page Progressive Web framework Retrieved from " https://en.wikipedia.org/w/index.php?title=Canvas_element&oldid=1348381325 " Categories : HTML tags HTML5 Hidden categories: Articles with short description Short description matches Wikidata CS1 maint: deprecated archival service Webarchive template wayback links This page was last edited on 12 April 2026, at 10:26  (UTC) . Page was rendered with Parsoid . Text is available under the Creative Commons Attribution-ShareAlike 4.0 License ; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy . Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc. , a non-profit organization. Privacy policy About Wikipedia Disclaimers Contact Wikipedia Legal & safety contacts Code of Conduct Developers Statistics Cookie statement Mobile view Search Search Toggle the table of contents Canvas element 22 languages Add topic 0