Subscribe

HTML meter tag

✍️

Showing percentages directly in HTML with the meter element

15 Mar, 2021 · 1 min read

Ever needs to showcase a percentage visually? HTML provides us with a super cool meter tag that can be used for this exact purpose.

It looks like this:

HTML Meter tag

HTML Meter attributes

The meter tag in general, works by just typing it as <meter>. However, it comes with some attributes we can leverage.

  • high: What is considered a high value
  • low: What is considered a low value
  • min: Starting point of the meter
  • max: Ending point of the meter
  • value: The current value

Considering this we can create a gauge that is on the low side:

<meter value="1" min="0" max="10" high="8" low="2"></meter>

HTML Low meter

Or we could create a reading that is considered high.

<meter value="9" min="0" max="10" high="8" low="2"></meter>

HTML High meter

Any other value could render in green.

<meter value="5" min="0" max="10" high="8" low="2"></meter>

HTML Meter tag

You can also have a play with the meters on Codepen.

See the Pen HTML meter tag by Chris Bongers (@rebelchris) on CodePen.

Browser support

The meter element is widely adopted. Just IE has some issues rendering it. You can place a fallback inside the meter element in the form of text or an image.

HTML Meter element browser support

Thank you for reading, and let’s connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter

Spread the knowledge with fellow developers on Twitter
Tweet this tip
Powered by Webmentions - Learn more

Read next 📖

Submit button outside the form

4 Dec, 2022 · 1 min read

Submit button outside the form

Trying out native dialog modals

8 Aug, 2022 · 3 min read

Trying out native dialog modals

Join 2099 devs and subscribe to my newsletter