Beginning HTML5 and CSS3 For Dummies
Book image
Explore Book Buy On Amazon

The HTML5 element lets you display a meter bar for various counters that you might manage over time to show readings for various metrics. The element includes these numerical attributes, whose values may be integers (that is, whole numbers) or decimal numbers:

  • value: The current measured value for your meter

  • high: States a value considered to be high for readings on this meter

  • low: States a value considered to be low for readings on this meter

  • max: Sets the upper bound for readings on this meter and its display

  • min: Sets the lower bound for readings on this meter and its display

  • optimum: States a value considered to be optimal for readings on this meter

Here’s a fully tricked-out markup example, shown in the figure displayed in Chrome:

Center-seeking meter

The figure shows the meter in the context of a complete HTML file, with some use of CSS to set off the meter display. The meter’s current value falls just below the optimal halfway mark.

image0.jpg

The high, low, and optimum attributes as well as the text enclosed between the opening and closing tags do not appear in the browser display of the meter. It’s probably best to think of this information as a kind of built-in documentation to help explain how the meter works.

To see and play around with meter markup (and value settings), visit Quackit.com.

For a nice demo of a meter at work (as you type into a text box, the character count goes up and the green meter bar gets longer), visit JSFIDDLE.

The following is a snippet of HTML markup that shows three different meter bars: one for storage space consumption, one for voter turnout, and one for tickets sold. Don’t scratch your head too much about it: It’s just a contrived example.

Storage space usage: 6 blocks used (out of 8 total)

Voter turnout:

75%

Tickets sold:

About This Article

This article is from the book:

About the book authors:

Ed Tittel is a 30-year veteran of the technology industry with more than 140 computing books to his credit, including the bestselling HTML For Dummies.

Chris Minnick runs Minnick Web Services. He teaches, speaks, and consults on web-related topics and has contributed to numerous books, including WebKit For Dummies.

This article can be found in the category: