JavaScript: Draw a rectangular shape
JavaScript Drawing: Exercise-1 with Solution
Draw Rectangle
Write a JavaScript program to draw the following rectangular shape.
Sample output:

Sample Solution:
HTML Code:
JavaScript Code:
Live Demo:
For more Practice: Solve these Related Problems:
- Write a JavaScript program to draw a rectangle with a vertical gradient fill that transitions from one color to another.
- Write a JavaScript program to draw a rectangle with a dashed border and a solid fill color.
- Write a JavaScript program to draw a rectangle with rounded corners and a shadow effect.
- Write a JavaScript program to draw a rotating rectangle that continuously spins around its center.
Improve this sample solution and post your code through Disqus.
Previous: javascript Drawing Exercises.
Next: Write a JavaScript program to draw a circle.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics