devxlogo

Draw a Simple Bar Chart in HTML

Draw a Simple Bar Chart in HTML

There are a lot of graphics packages for Web pages on the market, but sometimes you still want a homegrown solution. Using just HTML, it is possible to create simple bar charts. The trick is to embed tables inside a table and change the width property of the

tag of the inner table. To create a simple positive only bar chart, use this template. Just repeat the code between the

tag for each item you want to display. Note that there is a blank space in the

field. Without this blank space, the bar would not be displayed in Netscape.

 
Item 1
37%

This code produces this bar chart:

Item 1
37%

It is a little trickier if you want to display positive and negative data. Instead of having one nested table, you have two tables, each nested in its own

tag. Also, you have to change the alignment so that negatives are right-aligned while positives are left-aligned. You can play with the widths of the

tags of the outside table for different effects.

 
Item 1
15%
Item 2
-3%

This code produces this bar chart:

Item 1
15%
Item 2
-3%
See also  Small Business Strategies with Venmo
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist