- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to 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>
- Related Articles
- How do we display a script in HTML?
- How to work with Scalable Vector Graphics (SVG) in HTML5?
- Use HTML with jQuery to make a form
- Enclose a text to make it blink with HTML.
- How do I make an executable from a Python script?
- How to set the script to be executed asynchronously in HTML?
- How to make a div center align in HTML?
- Menu not visible in IE8. How to make it visible with HTML?
- How to match bold fields in a HTML script using a regular expression in Java?
- How to make text bold in HTML?
- How to make text italic in HTML?
- Execute a script when a user navigates to a page in HTML?
- HTML DOM Script Object
- How to create SVG graphics using JavaScript?
- How to make page links in HTML Page?

Advertisements