<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>HTML5 Doctor &#187; meter</title>
	<atom:link href="http://html5doctor.com/tag/meter/feed/" rel="self" type="application/rss+xml" />
	<link>http://html5doctor.com</link>
	<description>helping you implement HTML5 today</description>
	<lastBuildDate>Tue, 27 Jul 2010 14:36:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Measure up with the meter tag</title>
		<link>http://html5doctor.com/measure-up-with-the-meter-tag/</link>
		<comments>http://html5doctor.com/measure-up-with-the-meter-tag/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 13:31:41 +0000</pubDate>
		<dc:creator>Tom Leadbetter</dc:creator>
				<category><![CDATA[Elements]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[meter]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=823</guid>
		<description><![CDATA[
			
				
			
		
HTML5 offers several useful new elements, to add further  meaning to the markup of a page. These new elements include time,  mark and here is another one, meter. It is an inline element so it can be used inside most elements, including a header or a paragraph.
What does it say in the spec?
The [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fhtml5doctor.com%2Fmeasure-up-with-the-meter-tag%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fhtml5doctor.com%2Fmeasure-up-with-the-meter-tag%2F&amp;source=html5doctor&amp;style=normal&amp;service=is.gd" height="61" width="50" /><br />
			</a>
		</div>
<p>HTML5 offers several useful new elements, to add further  meaning to the markup of a page. These new elements include <code>time</code>,  <code><a href="http://html5doctor.com/draw-attention-with-mark/">mark</a></code> and here is another one, <code>meter</code>. It is an inline element so it can be used inside most elements, including a header or a paragraph.</p>
<h2>What does it say in the spec?</h2>
<blockquote><p>The <a href="http://dev.w3.org/html5/spec/Overview.html#the-meter-element">meter</a> element <a href="http://dev.w3.org/html5/spec/Overview.html#represents">represents</a> a scalar measurement within a known range, or a fractional value; for example  disk usage, the relevance of a query result, or the fraction of a voting  population to have selected a particular candidate.</p></blockquote>
<p>When I first read about the meter tag, I immediately thought  it would be useful for profile pages, such as height and weight, and maybe age,  marked up in a nice definition list. However, the third line of the spec says</p>
<blockquote><p>The <a href="http://dev.w3.org/html5/spec/Overview.html#the-meter-element">meter</a> element also does not represent a scalar value of arbitrary range — for example, it would be <strong>wrong</strong> to use this to report a weight, or height, unless there is a known maximum  value</p></blockquote>
<p>So there goes my idea. The emphasis of the spec definition  is <q><strong>“a scalar measurement within a known  range&#8221;</strong></q>. We’ll go through some sample usage now but I still think it would add useful meaning to a sportsman’s profile page for example.</p>
<h2>Attributes</h2>
<p>There are six attributes allowed with the meter tag: <strong>value</strong>, <strong>min</strong>,  <strong>max</strong>, <strong>high</strong>,  <strong>low</strong> and <strong>optimum</strong>. As we&#8217;ll mention later, the emphasis is on the author to use these correctly.</p>
<dl>
<dt>Value</dt>
<dd>This is what will be parsed out &#8211; the actual value. If you do not use the value attribute, then the first number inside the tag is the value: <code>&lt;meter&gt; <strong>2</strong> out of 10&lt;/meter&gt;</code>. If a real number is not used, then the value is zero. </dd>
<dt>Min</dt>
<dd>The minimum allowed value. If there is no min attribute, then it assumes the minimum is zero. If it is not specified then the value is 0.</dd>
<dt>Max</dt>
<dd>The maximum allowed value. If the maximum value is less than the minimum value, then the minimum value is used as the max. If it is not specified then the value is 1. However, if it is possible to specify the value of this in the content &#8211; such as a percentage sign, as the maximum then will be 100%</dd>
<dt>Low</dt>
<dd>This is considered to be the low part of the value range. It must be less than or equal to the value of the high attribute. Also, if the low value is less than the min value, then the low value is the same as the min value.</dd>
<dt>High</dt>
<dd>This is considered to be the high part of the value range. If the high value is less than the low boundary, then the high value is the same as the low value. Also, if the high value is greater than the max value, then the high value is the same as the high value.</dd>
<dt>Optimum</dt>
<dd>This is considered to be the optimum value and needs to be somewhere between <strong>min</strong> and <strong>max</strong>. It can be greater than the <strong>high</strong> attribute</dd>
</dl>
<h2>Let’s have a look at some examples</h2>
<h3>A voting or rating tool</h3>
<pre><code>&lt;p&gt;Your score is:  &lt;meter&gt;2 out of 10&lt;/meter&gt;&lt;/p&gt;</code></pre>
<p>We can give this further meaning by adding min and max attributes</p>
<pre><code>&lt;p&gt;Your score is: &lt;meter min="0" max="10"&gt;2 out of 10&lt;/meter&gt;&lt;/p&gt;</code></pre>
<pre><code>&lt;p&gt;Your score is: &lt;meter value="91" min="0" max="100" low="40" high="90" optimum="100"&gt;A+&lt;/meter&gt;&lt;/p&gt;</code></pre>
<h3>Without the attributes</h3>
<p>You do not always need to use an attribute with the meter tag. You could use</p>
<pre><code>&lt;meter&gt;80%&lt;/meter&gt;</code></pre>
<p>Because the max value is going to be 100% (unless you always  give that extra 10 <img src='http://html5doctor.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  ). You can also use fractions as the range is within itself, such as</p>
<pre><code>&lt;meter&gt;3/4&lt;/meter&gt;</code></pre>
<h2>Some real world examples</h2>
<h3>Christmas Calendar/Countdown</h3>
<pre><code>&lt;p&gt;Christmas is in &lt;meter value ="30" min="1" max="366" title="days"&gt;30 days!&lt;/p&gt;</code></pre>
<p>Notice that the title attribute can be used to specify the  unit (so we can use &#8220;centimeters&#8221; or &#8220;lbs&#8221;, and so on).</p>
<h3>Just Giving</h3>
<p>We could also use <code>meter</code> on the fundraising website <a href="http://www.justgiving.com/">Justgiving</a>.</p>
<p><img class="alignnone size-full wp-image-855" title="just-giving-example" src="/wp-content/uploads/2009/08/just-giving-example.jpg" alt="Screengrab from justgiving.com showing how the meter element could be used" width="600" height="200" /></p>
<p><a href="http://www.justgiving.com/DanDannyKirsty/">This page</a>, for example, would use</p>
<pre><code>&lt;dl&gt;
  &lt;dt&gt;Target&lt;/dt&gt;
  &lt;dd&gt;&lt;meter min="145" value="145" title="pounds"&gt;&pound;145&lt;/meter&gt;&lt;/dd&gt;
  &lt;dt&gt;Amount raised so far&lt;/dt&gt;
  &lt;dd&gt;&lt;meter min="0" max="1000" low="50" high="125" value="145" optimum="145" title="pounds"&gt;&pound;145&lt;/meter&gt;&lt;/dd&gt;
&lt;/dl&gt;</code></pre>
<h2>Incorrect use</h2>
<h3>Empty tag</h3>
<p>If you used</p>
<pre><code>&lt;meter min="0" max="100" value="75"&gt;&lt;/meter&gt;
</code></pre>
<p>Nothing will display on your page – it is noted in the spec</p>
<blockquote><p>The recommended way of giving the value is to include it as  contents of the element</p></blockquote>
<p>So you need to put something in the content of the tag and it doesn&#8217;t necessarily have to be a number. The spec has a good example of this</p>
<pre><code>&lt;p&gt;<strong>&lt;meter value="0.5"&gt;Moderate activity,&lt;/meter&gt;</strong> Usenet, 618 subscribers&lt;/p&gt;
&lt;p&gt;&lt;meter value="0.25"&gt;Low activity,&lt;/meter&gt; Usenet, 22 subscribers&lt;/p&gt;
&lt;p&gt;&lt;meter value="0.25"&gt;Low activity,&lt;/meter&gt; Usenet, 66 subscribers&lt;/p&gt;
</code></pre>
<p>Which could be used to produce on-screen information as shown</p>
<p><img src="/wp-content/uploads/2009/09/sample-meter.png" alt="Example usage of meter showing the number of subscribers" width="332" height="178" /></p>
<p>As I noted earlier, it is incorrect to use as a weight or height, unless there is a maximum value. The spec gives this example:</p>
<pre>&lt;p&gt;The grapefruit pie had a radius of &lt;meter&gt;12cm&lt;/meter&gt;  and a height of &lt;meter&gt;2cm&lt;/meter&gt;.&lt;/p&gt; &lt;!-- <strong>BAD!</strong> --&gt;</pre>
<blockquote><p>Instead, one would either not include the meter element, or use the meter element with a defined range to give the dimensions in context compared to other pies:</p></blockquote>
<pre>&lt;p&gt;The grapefruit pie had a radius of 12cm and a height of 2cm.&lt;/p&gt;
&lt;dl&gt;
&lt;dt&gt;Radius: &lt;dd&gt; &lt;meter min=0 max=20 value=12&gt;12cm&lt;/meter&gt;
&lt;dt&gt;Height: &lt;dd&gt; &lt;meter min=0 max=10 value=2&gt;2cm&lt;/meter&gt;
&lt;/dl&gt;</pre>
<p>Whilst the above is now a correct usage of the meter tag, how do I know the max height or radius of a grapefruit? I would prefer to use a meter tag there but instead I&#8217;d probably just use a definition list to display the information.</p>
<h2>Browser support</h2>
<p>The meter tag works in at least the following browsers Safari  4, Firefox 3.5, Chrome 2, Opera 9.64 naturally. The following javascript is needed for IE 6, 7 and 8 (see Remy&#8217;s article about Getting <abbr>HTML</abbr>5 to play nicely in older browsers.</p>
<pre><code> &lt;!--[if IE]&gt;
  &lt;script  src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt;
  &lt;![endif]--&gt;</code></pre>
<p>As it is an inline element, you don’t need to do anything  special with the CSS.</p>
<h2>Conclusion</h2>
<p>If I were to use</p>
<pre><code>&lt;meter value="1000" min="0"  max="500"&gt;100%&lt;/meter&gt;</code></pre>
<p>Obviously there are  inconsistencies. Now, I am  just being silly there but what the user will see on the screen is “100%&#8221; when the value is actually 1000. The meter tag puts the emphasis on the author to make sure that they are using this nice, new semantic tag,well, semantically and correctly. </p>
<p>The attributes can appear to be quite confusing but the spec is very detailed for this element. I do think they may have missed a trick by not allowing it to be used to give a stand-alone height or weight but overall I see the meter tag being used a lot in apps and on webpages, perhaps if used with javascript, it could generate live graphs and charts (though we can also use canvas for this).</p>
<p>Finally, I also wonder if <code>meter</code> allows for negative values? For example if the temperature was going to be between -10 and 5 degrees could I use <code>meter</code> to mark that up? I&#8217;d love to know your thoughts.</p>
<h3>Useful Links</h3>
<ul>
<li><a href="http://www.whatwg.org/specs/web-apps/current-work/#the-meter-element">http://www.whatwg.org/specs/web-apps/current-work/#the-meter-element</a></li>
</ul>
<div id="crp_related">
<h3>Related Posts:</h3>
<ul>
<li><a href="http://html5doctor.com/reviewing-html5-for-web-designers/" rel="bookmark" class="crp_title">Reviewing HTML5 for Web Designers</a></li>
<li><a href="http://html5doctor.com/draw-attention-with-mark/" rel="bookmark" class="crp_title">Draw attention with mark</a></li>
<li><a href="http://html5doctor.com/the-video-element/" rel="bookmark" class="crp_title">The video element</a></li>
<li><a href="http://html5doctor.com/small-hr-element/" rel="bookmark" class="crp_title">The small &amp; hr elements</a></li>
<li><a href="http://html5doctor.com/i-b-em-strong-element/" rel="bookmark" class="crp_title">The i, b, em, &amp; strong elements</a></li>
</ul>
</div>
<p>Share and Save:</p>
<p>	<a rel="nofollow"  href="http://twitter.com/home?status=Measure%20up%20with%20the%20meter%20tag%20-%20http%3A%2F%2Fhtml5doctor.com%2Fmeasure-up-with-the-meter-tag%2F" title="Twitter"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhtml5doctor.com%2Fmeasure-up-with-the-meter-tag%2F&amp;title=Measure%20up%20with%20the%20meter%20tag&amp;bodytext=HTML5%20offers%20several%20useful%20new%20elements%2C%20to%20add%20further%20%20meaning%20to%20the%20markup%20of%20a%20page.%20These%20new%20elements%20include%20time%2C%20%20mark%20and%20here%20is%20another%20one%2C%20meter.%20It%20is%20an%20inline%20element%20so%20it%20can%20be%20used%20inside%20most%20elements%2C%20including%20a%20header%20or%20a%20" title="Digg"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fhtml5doctor.com%2Fmeasure-up-with-the-meter-tag%2F" title="Sphinn"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fhtml5doctor.com%2Fmeasure-up-with-the-meter-tag%2F&amp;title=Measure%20up%20with%20the%20meter%20tag" title="Reddit"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhtml5doctor.com%2Fmeasure-up-with-the-meter-tag%2F&amp;title=Measure%20up%20with%20the%20meter%20tag&amp;notes=HTML5%20offers%20several%20useful%20new%20elements%2C%20to%20add%20further%20%20meaning%20to%20the%20markup%20of%20a%20page.%20These%20new%20elements%20include%20time%2C%20%20mark%20and%20here%20is%20another%20one%2C%20meter.%20It%20is%20an%20inline%20element%20so%20it%20can%20be%20used%20inside%20most%20elements%2C%20including%20a%20header%20or%20a%20" title="del.icio.us"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhtml5doctor.com%2Fmeasure-up-with-the-meter-tag%2F&amp;title=Measure%20up%20with%20the%20meter%20tag" title="StumbleUpon"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fhtml5doctor.com%2Fmeasure-up-with-the-meter-tag%2F" title="Technorati"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.netvibes.com/share?title=Measure%20up%20with%20the%20meter%20tag&amp;url=http%3A%2F%2Fhtml5doctor.com%2Fmeasure-up-with-the-meter-tag%2F" title="Netvibes"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fhtml5doctor.com%2Fmeasure-up-with-the-meter-tag%2F&amp;t=Measure%20up%20with%20the%20meter%20tag" title="Facebook"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fhtml5doctor.com%2Fmeasure-up-with-the-meter-tag%2F&amp;title=Measure%20up%20with%20the%20meter%20tag&amp;annotation=HTML5%20offers%20several%20useful%20new%20elements%2C%20to%20add%20further%20%20meaning%20to%20the%20markup%20of%20a%20page.%20These%20new%20elements%20include%20time%2C%20%20mark%20and%20here%20is%20another%20one%2C%20meter.%20It%20is%20an%20inline%20element%20so%20it%20can%20be%20used%20inside%20most%20elements%2C%20including%20a%20header%20or%20a%20" title="Google Bookmarks"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.friendfeed.com/share?title=Measure%20up%20with%20the%20meter%20tag&amp;link=http%3A%2F%2Fhtml5doctor.com%2Fmeasure-up-with-the-meter-tag%2F" title="FriendFeed"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fhtml5doctor.com%2Fmeasure-up-with-the-meter-tag%2F&amp;t=Measure%20up%20with%20the%20meter%20tag" title="HackerNews"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fhtml5doctor.com%2Fmeasure-up-with-the-meter-tag%2F&amp;title=Measure%20up%20with%20the%20meter%20tag&amp;source=HTML5+Doctor+helping+you+implement+HTML5+today&amp;summary=HTML5%20offers%20several%20useful%20new%20elements%2C%20to%20add%20further%20%20meaning%20to%20the%20markup%20of%20a%20page.%20These%20new%20elements%20include%20time%2C%20%20mark%20and%20here%20is%20another%20one%2C%20meter.%20It%20is%20an%20inline%20element%20so%20it%20can%20be%20used%20inside%20most%20elements%2C%20including%20a%20header%20or%20a%20" title="LinkedIn"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.newsvine.com/_tools/seed&amp;save?u=http%3A%2F%2Fhtml5doctor.com%2Fmeasure-up-with-the-meter-tag%2F&amp;h=Measure%20up%20with%20the%20meter%20tag" title="NewsVine"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhtml5doctor.com%2Fmeasure-up-with-the-meter-tag%2F&amp;t=Measure%20up%20with%20the%20meter%20tag&amp;s=HTML5%20offers%20several%20useful%20new%20elements%2C%20to%20add%20further%20%20meaning%20to%20the%20markup%20of%20a%20page.%20These%20new%20elements%20include%20time%2C%20%20mark%20and%20here%20is%20another%20one%2C%20meter.%20It%20is%20an%20inline%20element%20so%20it%20can%20be%20used%20inside%20most%20elements%2C%20including%20a%20header%20or%20a%20" title="Tumblr"><img src="http://html5doctor.com/wp-content/plugins/sociable/images/tumblr.png" title="Tumblr" alt="Tumblr" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
<p><a href="http://html5doctor.com/measure-up-with-the-meter-tag/" rel="bookmark">Measure up with the meter tag</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on October 7, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/measure-up-with-the-meter-tag/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
	</channel>
</rss>
