<?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>Wed, 01 Feb 2012 09:28:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Your Questions Answered #11</title>
		<link>http://html5doctor.com/your-questions-answered-11/</link>
		<comments>http://html5doctor.com/your-questions-answered-11/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 14:00:13 +0000</pubDate>
		<dc:creator>Richard Clark</dc:creator>
				<category><![CDATA[Questions]]></category>
		<category><![CDATA[boilerplate]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[hgroup]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[meter]]></category>
		<category><![CDATA[placeholder]]></category>
		<category><![CDATA[progress]]></category>
		<category><![CDATA[web forms]]></category>

		<guid isPermaLink="false">http://html5doctor.com/?p=2328</guid>
		<description><![CDATA[<p>The clinic is busy as ever with more <abbr>HTML</abbr>5 ailments. This week, we'll show you how (and whether) to store a <code>&#60;canvas&#62;</code> on the server, whether to use <code>&#60;progress&#62;</code> or <code>&#60;meter&#62;</code>, more on <code>&#60;header&#62;</code>, the <code>placeholder</code> attribute, and <abbr>HTML</abbr>5 minification.</p>]]></description>
			<content:encoded><![CDATA[<p><img src="http://html5doctor.com/wp-content/uploads/2009/07/html5doctor-treatment.gif" alt="Doctor treating a patient illustration" class="alignright size-full wp-image-424" /> The clinic is busy as ever with more <abbr>HTML</abbr>5 ailments. This week, we&#8217;ll show you how (and whether) to store a <code>&lt;canvas&gt;</code> on the server, whether to use <code>&lt;progress&gt;</code> or <code>&lt;meter&gt;</code>, more on <code>&lt;header&gt;</code>, the <code>placeholder</code> attribute, and <abbr>HTML</abbr>5 minification.</p>
    
    <section>
      <h2>Getting info from a canvas to the server</h2>
      <p>Stephen asked:</p>
      <blockquote>
        <p>I want to use a canvas element as a layout plan and allow people to move things about and the like but I then want to be able to submit the changed layout to the server so it can be kept not just as a bitmap but as the various current layout of the plan.  Is this possible?</p>
      </blockquote>
      <p>You could call <code>canvas.toDataURL()</code> and store this output on the server. (Note that <code>canvas</code> is the <abbr>DOM</abbr> node and not the 2D context.) This will store the current state of your canvas, but it&#8217;s effectively a bitmap at this point. If you want to store the element for later editing, I&#8217;d suggest you use <abbr>SVG</abbr> instead. You can achieve the same graphical effect, but you&#8217;ll have access to the actual vector data since it&#8217;s <abbr>XML</abbr>.</p>

	  <p>Hope that helps,</p>
	  
	  <p>Remy</p>
    </section>
    
    <section>
      <h2>Progress or meter?</h2>
      <p>Pierre asked:</p>
      <blockquote>
        <p>Hello doctor,</p>

<p>I&#8217;m beginning with <abbr>HTML</abbr>5. I just wonder if I&#8217;m using the progress and meter elements correctly. Just imagine a player. Is it correct to use: the progress element to specify a load bar; the meter element to specify the volume set.</p>

<p>Thank you Doctor, have a good day. <img src='http://html5doctor.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
      </blockquote>
      <p><code>&lt;progress&gt;</code> is spot on for a loading bar, yes.</p>

	  <p><code>&lt;meter&gt;</code> is read only, however, so it&#8217;s not appropriate for a volume control. There are some examples in <a href="http://html5doctor.com/measure-up-with-the-meter-tag/">Tom&#8217;s article on <code>&lt;meter&gt;</code></a>. To create a volume control, you could use one of the new input types specified in <abbr>HTML</abbr>5, perhaps <code>&lt;input type="range"&gt;</code>.</p>

	  <p>Cheers,</p>
	  
	  <p>Rich</p>
    </section>
    
    <section>
      <h2>Headers</h2>
      <p>Brad asked:</p>
      <blockquote>
        <p>Having read you can use the header tag within almost any other element, is it fair to say you no longer &#8220;design&#8221; the header but simply design the elements in each header?  How does that work?  Would you use header classes?</p>
		
        <p>In the past you define your header with an image or text etc.  You can no longer do that if you use multiple headers?</p>
      </blockquote>
      <p>The <code>&lt;header&gt;</code> element should be used if you have any related information within the &#8220;header&#8221; of that section that needs to be grouped. This means, for example, it isn&#8217;t necessary to wrap a lone <code>&lt;h1&gt;</code> in a <code>&lt;header&gt;</code> element. Also remember that the header doesn&#8217;t <em>have</em> to appear at the top of a section of page.</p>

    <p>Our articles on the <a href="http://html5doctor.com/the-header-element/"><code>&lt;header&gt;</code> element</a> and <a href="http://html5doctor.com/the-hgroup-element/"><code>&lt;hgroup&gt;</code> element</a> explain this some more.</p>

    <p>Whether you need to use classes depends on your site.</p>

    <p>Ta,</p>
    
    <p>Rich</p>
    </section>
    
    <section>
      <h2>The <code>placeholder</code> attribute</h2>
      <p>José asked:</p>
      <blockquote>
        <p>I recall once having seen text inputs that had tips inside them. They didn&#8217;t need Javascript in order to manage those tips. Would you consider discussing that a little better? That&#8217;d be great! Thanks!</p>
      </blockquote>
      <p>We&#8217;re publishing an article on forms shortly, so be sure to look out for it.</p>

	  <p>Meanwhile, you&#8217;re looking for the <code>placeholder</code> attribute. Currently, this is supported only on Webkit browsers, although Mozilla is also working on it. You can use <code>placeholder</code> like this:</p>

      <pre><code>&lt;input placeholder="Search" title="Type your search here" ...&gt;</code></pre>
      
	  <p>We&#8217;ve also written a JavaScript solution using feature detection (i.e., it will check whether the browser supports <code>placeholder</code> and adds support if not). Just add <a href="http://gist.github.com/330318">this script</a> to the end of your markup (note that it should be the end since it needs to run once the <abbr>DOM</abbr> is ready).</p>

	  <p>Hope that helps,</p>
	  
	  <p>Bruce &amp; Remy</p>

    </section>
    
    <section id="html5-minified">
      <h2>HTML5 Minified</h2>
      <p>Grant asked:</p>
      <blockquote>
        <p>Hello! Big fan of your website. I wanted to know about the so called &#8220;HTML Minified&#8221; feature that allows you to strip the <code>html</code>, <code>head</code> and <code>body</code> tags from your page.</p>

		<p>The W3C Validator Conformance Checker for HTML5 says this is valid, but the Conformance Checker is beta and is supposedly unreliable. I haven&#8217;t heard from anywhere else that stripping these tags is a feature.</p>

		<p>So is it really a feature? Or just a bug (A BIG one at that) in the experimental validator? I know that it works, but I would like to see any confirmation other than the validator that this is in fact an intended standard before I start using it on my websites. Thanks!</p>
      </blockquote>
      <p>According to the spec, it is now explicitly permitted to omit all kinds of <del datetime="2010-07-31T13:33+09:00">elements</del> <ins datetime="2010-07-31T13:33+09:00">tags</ins>, including the ones you mention. Browsers are able to deduce the document structure based on context (e.g., some elements are only allowed within a <code>&lt;body&gt;</code> element) and will fix the <abbr>DOM</abbr> as they go. In fact, these have always been optional tags in <abbr>HTML</abbr> (but not <abbr>XHTML</abbr>).</p>

	  <p>Browsers are so good at this, though, because they’ve had to deal with the pants code out there on the interwebs. Going this route means you’re relying on browser error handling to render your document <del datetime="2010-07-31T13:34+09:00">(although said error handling has admittedly been standardised in <abbr>HTML</abbr>5)</del>. I personally see it as a more extreme version of quoting element attributes. Of course you don’t have to, but being strict makes errors much easier to find, helps out parsers that may not be as sophisticated as a full-fledged browser (like text editor syntax highlighting), and makes it easier for beginners and veterans alike to learn and use <abbr>HTML</abbr>.</p>

	  <p>In general, machines understand you better when you’re explicit, so I’d advise against omitting these elements.</p>
      
      <p>For more detailed articles on <abbr>HTML</abbr>5 minification, check out Remy&#8217;s <a href="http://html5doctor.com/html-5-boilerplates/">HTML5 Boilerplates</a> and Bruce&#8217;s <a href="http://www.brucelawson.co.uk/2010/a-minimal-html5-document/">A minimal HTML5 document</a>.</p>

	  <p>Peace,</p>
	  
	  <p>Oli</p>
    </section>
    
	<section>
		<h2>Got a question for us?</h2>
		<p>That wraps up this round of questions. If you&#8217;ve got a query about the <abbr>HTML</abbr>5 spec or how to implement it, you can <a href="http://html5doctor.com/ask-the-doctor/">get in touch</a> with us and we&#8217;ll do our best to help.</p>
	</section>
<div id="crp_related"><h3>Related Posts:</h3><ul class="related"><li><a href="http://html5doctor.com/your-questions-answered-9/" rel="bookmark" class="crp_title">Your Questions Answered 9</a></li><li><a href="http://html5doctor.com/your-questions-answered-7/" rel="bookmark" class="crp_title">Your Questions Answered #7</a></li><li><a href="http://html5doctor.com/your-questions-13/" rel="bookmark" class="crp_title">Your Questions #13</a></li><li><a href="http://html5doctor.com/your-questions-5/" rel="bookmark" class="crp_title">Your Questions Answered #5</a></li><li><a href="http://html5doctor.com/your-questions-answered-8/" rel="bookmark" class="crp_title">Your Questions Answered #8</a></li></ul></div><p><a href="http://html5doctor.com/your-questions-answered-11/" rel="bookmark">Your Questions Answered #11</a> originally appeared on <a href="http://html5doctor.com">HTML5 Doctor</a> on July 30, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://html5doctor.com/your-questions-answered-11/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<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[<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 <strong>zero</strong>. </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 <strong>0</strong>.</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 <strong>min </strong>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 <strong>max</strong> 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;£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;£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 class="related">
<li><a href="http://html5doctor.com/your-questions-answered-11/" rel="bookmark" class="crp_title">Your Questions Answered #11</a></li>
<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-abbr-element/" rel="bookmark" class="crp_title">The abbr element</a></li>
<li><a href="http://html5doctor.com/small-hr-element/" rel="bookmark" class="crp_title">The small &amp; hr elements</a></li>
</ul>
</div>
<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>37</slash:comments>
		</item>
	</channel>
</rss>

