October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

CSS Bar Charts: Style Data with CSS and Progressive Enhancement

Use meaningful HTML for chart categories and values, then layer CSS bars on top so the data remains understandable without the visual styling.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Build a CSS bar chart by keeping each category and value in meaningful HTML, then using CSS to display that data as bars. The chart should remain understandable when styles are missing, changed, or unavailable: labels and values—not bar length or color alone—must communicate the data.

Start with data, then add the bars

CSS controls presentation; it does not supply the meaning of the chart. Choose HTML that fits the data and how people will use it. For a small, static set of category-and-value pairs, a list can provide a useful textual structure. The example below uses a custom property to set each bar’s width, while the category and value remain visible text.

As an Amazon Associate I earn from qualifying purchases.

<ul class="chart">
  <li class="chart__item" style="--bar-width: 80%">
    <span class="chart__label">North</span>
    <span class="chart__track" aria-hidden="true">
      <span class="chart__bar"></span>
    </span>
    <span class="chart__value">80 units</span>
  </li>
  <li class="chart__item" style="--bar-width: 55%">
    <span class="chart__label">South</span>
    <span class="chart__track" aria-hidden="true">
      <span class="chart__bar"></span>
    </span>
    <span class="chart__value">55 units</span>
  </li>
  <li class="chart__item" style="--bar-width: 30%">
    <span class="chart__label">West</span>
    <span class="chart__track" aria-hidden="true">
      <span class="chart__bar"></span>
    </span>
    <span class="chart__value">30 units</span>
  </li>
</ul>

These sample values are illustrative. In a real chart, calculate each width against a clearly chosen scale and make that scale clear to readers—for example, explain the unit and what the full track represents. A width percentage without context can make comparisons misleading.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
.chart {
  display: grid;
  gap: 0.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.chart__item {
  display: grid;
  grid-template-columns: 5rem minmax(4rem, 1fr) 6rem;
  align-items: center;
  gap: 0.75rem;
}

.chart__track {
  display: block;
  min-height: 1rem;
  background: #e5e7eb;
}

.chart__bar {
  display: block;
  width: var(--bar-width);
  min-height: 1rem;
  background: #1769aa;
}

@media (max-width: 30rem) {
  .chart__item {
    grid-template-columns: 4rem minmax(3rem, 1fr) 5rem;
    gap: 0.5rem;
  }
}

The track is hidden from assistive technology here because it is decorative; the category and value are already supplied as text. The list remains meaningful if the CSS fails to load. If you remove the bar-specific styling, readers can still identify every category and its value.

#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Keep the chart understandable without visual styling

Do not make bar length, position, or color the only way to learn a value. Keep labels and values in the document, use sufficient contrast for the visual bars, and add context such as units or the scale when readers need it to interpret comparisons. For a chart with many data points or a more complex relationship, provide an equivalent readable representation—often a table or a concise description of the important pattern alongside the chart.

W3C WAI’s guidance on complex images explains that visual presentations can convey structure that assistive technologies may not receive automatically. Applying that principle to a CSS chart means checking that the same essential information is available in text; the guidance does not prescribe one universal markup recipe for CSS charts. W3C WAI: Complex Images

Use HTML semantics that fit the data

A list is one reasonable option for a simple set of category/value pairs, not a mandatory pattern. If the data is naturally tabular, use a table; if the chart is part of a larger interactive component, choose markup that expresses that structure and behavior. Prefer native HTML semantics where they fit instead of adding ARIA roles without need. MDN’s accessibility guidance recommends using the correct semantic HTML element when it already provides the relevant semantics and behavior. MDN: ARIA and accessibility

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

There is no single best implementation for every chart. The choice depends on the data, complexity, interaction, and how the equivalent information will be exposed. Whatever representation you choose, keep the underlying values available as understandable content rather than relying on the visual effect to carry their meaning.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

A data chart is not a progress bar

Static bars comparing categories represent data; they do not become progress indicators just because they look like bars. Do not add role="progressbar" to an ordinary chart. That role describes a range or progress state, and MDN points to native <progress> or <input type="range"> when those elements suit the use case. MDN: progressbar role

For an actual progress indicator showing that a region is loading, WAI-ARIA says to associate the status with that region using aria-describedby and set aria-busy="true" on the region while it loads. That guidance applies to real loading progress, not category/value charts. W3C: WAI-ARIA 1.2

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.