HTML & CSS
Article
By Adam Roberts

How to Draw a Rectangle in HTML

By Adam Roberts

If, for whatever reason, you sometimes feel like creating a rectangle using html/css, the below code is the easiest way to do so. A given rectangle can also be decorated using tags like background-color.

Here’s the code:

<div style="width:500px;height:100px;border:1px solid #000;">This is a rectangle!</div>

And here’s the result:

--ADVERTISEMENT--

This is a rectangle!

There you go: no fuss, no muss.

Recommended
Sponsors
The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account