
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Make Graphics with a Script in HTML
To make graphics with a script, use the <canvas> tag. The HTML <canvas> tag is for drawing graphics, animations, etc using scripting.
The following are the attributes of the <canvas> tag −
Attribute |
Value |
Description |
---|---|---|
height ![]() |
pixels |
Specifies the height of the canvas. |
width ![]() |
pixels |
Specifies the width of the canvas. |
Example
You can try to run the following code to implement <canvas> tag and create graphics −
<!DOCTYPE html> <html> <head> <title>HTML Canvas Tag</title> </head> <body> <canvas id = "newCanvas">Your browser does not support canvas tag.</canvas> <script> var c = document.getElementById('newCanvas'); var ctx = c.getContext('2d'); ctx.fillStyle = '#00AEEF'; ctx.fillRect(0,0,180,50); </script> </body> </html>
Advertisements