Home / Dashboard Widgets / Gantt Chart

Gantt Chart in HTML, CSS and JavaScript

A Gantt chart shows a project plan as bars on a timeline. This free template draws one with plain SVG and vanilla JavaScript, no chart library. The example shows a cafe renovation plan with tasks and milestones.

Open live demoDownload HTML fileView code on GitHub
Gantt Chart made with HTML and JavaScript showing a cafe renovation plan with tasks and milestones

What is a gantt chart?

A Gantt chart shows a project plan as bars on a timeline. Each task gets a row, and its bar runs from its start date to its end date. The filled part shows how much is done.

Arrows show which tasks must finish before others can start, diamonds mark key dates, and a today line shows at a glance what is on track and what is running late.

At a glance

Best for
Project plans with dates and order
Data you need
A start date, end date and progress for each task
Skip it when
Hundreds of tasks. Group them into phases.
Made with
HTML, CSS and vanilla JavaScript. No library.

When to use a gantt chart

  • Building, renovation and event projects
  • Software releases and marketing launches
  • Course and training schedules
  • Any plan you share with a team or client

When to pick another chart

What you get in this template

How the code works

Here is a short version of the idea behind this gantt chart. The full file adds the axis, labels, tooltips, sorting and resizing on top of it.

const tasks = [['Permits', '2026-08-10', '2026-08-28', 100], ['Plumbing', '2026-09-07', '2026-09-25', 80], ['Painting', '2026-10-12', '2026-10-21', 0]];
const start = new Date('2026-08-01'), end = new Date('2026-11-01');
const x = d => 120 + (new Date(d) - start) / (end - start) * 460;

tasks.forEach(([name, from, to, done], i) => {
  const y = 30 + i * 40;
  drawText(110, y + 18, name, 'end');
  drawRect(x(from), y, x(to) - x(from), 24, '#f0c9b8');
  drawRect(x(from), y, (x(to) - x(from)) * done / 100, 24, '#b5552d');
});
drawLine(x('2026-09-23'), 20, x('2026-09-23'), 150, '#b5552d', 2, '5 4'); // today

The example uses four tiny helpers that create SVG shapes. Put them above the code and it runs as is.

const svg = document.querySelector('svg');
function make(tag, attrs) {
  const n = document.createElementNS('http://www.w3.org/2000/svg', tag);
  for (const k in attrs) n.setAttribute(k, attrs[k]);
  svg.appendChild(n);
  return n;
}
function drawRect(x, y, width, height, fill) { return make('rect', { x, y, width, height, fill }); }
function drawCircle(cx, cy, r, fill) { return make('circle', { cx, cy, r, fill }); }
function drawLine(x1, y1, x2, y2, stroke, width, dash) {
  return make('line', { x1, y1, x2, y2, stroke, 'stroke-width': width || 1, 'stroke-dasharray': dash || 'none' });
}
function drawText(x, y, str, anchor) {
  const t = make('text', { x, y, 'text-anchor': anchor || 'start' });
  t.textContent = str;
  return t;
}

How to add it to your website

  1. Download the file. Click Download HTML file above. You get one file called gantt-chart.html with everything inside.
  2. Change the data. Open the file in any code editor and find the DATA list near the bottom. Replace the names and numbers with your own.
  3. Change the colors and text. Colors are at the top of the style tag. The title, subtitle and main point are plain HTML near the top of the body.
  4. Put it online. Upload the file to any host, such as GitHub Pages, Netlify or your own server, or paste it into your site. There is no build step.

Questions people ask

What is a Gantt chart?

A Gantt chart is a bar chart of a project plan, with one bar per task placed on a timeline from its start to its end date.

Who invented the Gantt chart?

It is named after Henry Gantt, an American engineer who made it popular around 1910 for planning factory work.

What do the arrows in a Gantt chart mean?

They are dependencies. An arrow from one task to another means the second cannot start until the first is finished.

How do I show progress in a Gantt chart?

Fill part of each bar in a darker color, sized to the share that is done, and add a today line so late tasks stand out.

More dashboard widgets