<!doctype html>
<html  data-current="post" lang="en-GB">

	<head>
  <!-- COMMON TAGS -->
<meta charset="utf-8">
<title itemprop="name">My problem with HTML 5 - Styling &lt;meter&gt;</title>
<!-- Search Engine -->
<meta name="description" itemprop="description" content="The blog of Steve - Web* Developer">
<!-- Twitter -->
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="My problem with HTML 5 - Styling &lt;meter&gt;">
<meta name="twitter:description" content="The blog of Steve - Web* Developer">
<meta name="twitter:site" content="@steveworkman">
<meta name="twitter:creator" content="@steveworkman">

<!-- Twitter - Article -->
<!-- Open Graph general (Facebook, Pinterest & Google+) -->
<meta name="og:title" content="My problem with HTML 5 - Styling &lt;meter&gt;">
<meta name="og:description" content="The blog of Steve - Web* Developer">

<meta name="og:url" content="https://steveworkman.com">
<meta name="og:site_name" content="The blog of Steve - Web* Developer">
<meta name="og:locale" content="en-GB">
<meta name="og:type" content="article">
<!-- Open Graph - Article -->
<meta name="article:section" content="Web Development">
<meta name="article:published_time" content="2009-10-15T00:00:00.000Z">
<meta name="article:author" content="Steve Workman">
<meta name="article:tag" content="post,HTML5">

<link rel="alternate" type="application/rss+xml" href="https://steveworkman.com/feed.xml" />
<link rel="me" href="https://webperf.social/@steveworkman" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  
  <style>:root{--turkey:#fff0eb;--white:#fff;--blue:#1777af;--headingBackground:#bbdce8;--textColor:#282828;--visibleGrey:#ccc;--pageBackground:#fff;--articleBorder:#fff;color-scheme:light dark}@media (prefers-color-scheme:dark){:root{--turkey:#fff0eb;--white:#fff;--blue:#29b0ff;--headingBackground:#083444;--textColor:#f5f5f5;--visibleGrey:#ccc;--pageBackground:#333;--articleBorder:#2a2a2a}}*,:after,:before{box-sizing:border-box}body,html{color:var(--textColor);font-family:Avenir,Avenir Next,-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif;margin:0 auto;padding:0}header{grid-area:header}main{grid-area:main}aside{grid-area:aside}footer{grid-area:footer}body{background-color:var(--pageBackground);display:grid;grid-template-areas:"header header header" ". main main" ". aside aside" "footer footer footer";grid-template-columns:auto 3fr 1fr;grid-template-rows:auto 1fr auto auto;height:100vh;max-width:50em}@media screen and (min-width:750px){body{grid-template-areas:"header header header" ". main aside" "footer footer footer";grid-template-rows:auto 1fr auto}main{max-width:37.5em}}code,p,pre{line-height:1.5}a[href],a[href]:visited{color:var(--blue)}a[href]:not(:hover){text-decoration:none}footer,header,main{padding:1em}main{margin:0 auto;max-width:100%;padding-bottom:2em}main :first-child,main>article :first-child{margin-top:0}pre{direction:ltr;font-size:14px;-webkit-hyphens:none;hyphens:none;margin:.5em 0;padding:1em;-moz-tab-size:2;-o-tab-size:2;tab-size:2;text-align:left;white-space:pre;word-break:normal;word-spacing:normal}blockquote{position:relative}blockquote:before{color:var(--visibleGrey);content:"\201C";font-family:Georgia,Times New Roman,Times,serif;font-size:6rem;left:-2.5rem;position:absolute;top:-.5rem}header>em{display:block;font-size:2em;font-style:normal;font-weight:700;margin:.67em 0}header nav ul{list-style:none;padding:0}header nav ul :first-child{margin-left:0}header nav li{display:inline-block;margin:0 .5em}header nav li a[href]:not(:hover){text-decoration:none}header nav li a[data-current="current item"]{font-weight:700;text-decoration:underline}article{border-bottom:1px solid #eee;border-bottom:1px solid var(--articleBorder);margin-bottom:1em;padding-bottom:1em}article>h1,article>h2,article>header{background-color:var(--headingBackground);border-radius:.5em 0 0 0;font-size:2em;line-height:1.2;margin-bottom:.75em;padding:.25em .5em}article>h1>a[href],article>h1>a[href]:visited,article>h2>a[href],article>h2>a[href]:visited{color:var(--textColor)}article>header>h1{font-size:1.2em;margin-bottom:.25em}article>header>.subtitle{font-size:.8rem;margin-bottom:0}article>header>.subtitle>small{display:inline-block;width:50%}article>header>.subtitle>small:last-child{text-align:right}article img{display:block;margin-left:auto;margin-right:auto;max-width:100%;text-align:center}main>section>article>*{margin-bottom:.5em;margin-top:0}a[rel=tag],a[rel=tag]:visited{background-color:var(--pageBackground);border:1px solid var(--pageBackground);border-radius:.25em;color:var(--blue);display:inline-block;font-size:.625em;height:2em;letter-spacing:.1em;line-height:2em;margin:0 .5em .5em 0;padding:0 .5em;text-decoration:none;text-transform:uppercase;vertical-align:text-top}a[rel=tag]:hover{background-color:var(--blue);border:1px solid var(--blue);color:var(--pageBackground)}a[rel=tag]:last-child{margin-right:0}ul.taglist{font-size:.8em}ul.taglist li{padding-bottom:.25em;padding-top:.25em}form{display:grid;padding:2em 0}form label{display:none}button,input,textarea{font-family:Avenir,Avenir Next,sans-serif;font-size:1rem;margin-bottom:1em;padding:1em;width:100%}input,textarea{border:1px solid #000}button{background-color:var(--blue);border:1px solid var(--blue);color:var(--white);cursor:pointer}@media screen and (min-width:768px){:root{font-size:1.1rem}}.pagination>ol{list-style:none;padding:0}.pagination>ol>li{display:inline-block;width:50%}.pagination>ol>li.previous{text-align:right}table.speaking{border:1px solid var(--turkey);border-collapse:collapse}table.speaking td,table.speaking th{padding:.25em}table.speaking thead>tr{background-color:var(--headingBackground);border-bottom:1px solid var(--turkey)}table.speaking th{text-align:left}table.speaking .label{background-color:var(--headingBackground);border-radius:8px;color:var(--textColor);display:inline-block;padding:4px 8px}</style>
  
  <script></script>
  
<script src="https://paulirish.github.io/lite-youtube-embed/src/lite-yt-embed.js" async></script>
<link href="https://paulirish.github.io/lite-youtube-embed/src/lite-yt-embed.css" rel="stylesheet">
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-18282110-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-18282110-1');
</script>
</head>


	<body>

		<header>
			<em>
				<a href="/">Steve Workman&#39;s Blog</a>
			</em>
			<nav>
  <ul>
    <li><a href="/" >Home</a></li><li>
      <a href="/about/">About Steve</a>
    </li><li>
      <a href="/speaking/">Speaking</a>
    </li><li>
      <a href="/bookshelf/">CSS Bookshelf</a>
    </li></ul>
</nav>

		</header>

		<main>
			
<article>
  <header>
    <h1>My problem with HTML 5 - Styling &lt;meter&gt;</h1>
    <p class="subtitle">
      <small>
        Posted on <time datetime="2009-10-15T00:00:00.000Z">15 October 2009</time> by Steve Workman
      </small>
      <small>About 2 min reading time</small>
    </p>
  </header>

  <p>I consider myself quite a forward-looking chap. Apart from the occasional glance backwards to see IE6 still behind me and throw it some pity code every now and again, I try and use the latest technology and techniques whenever I can.</p>
<p>Looking forward then, to HTML 5, I'm met with a lot of optimism. These new elements, accessible web forms, canvas, SVG, are all going to save me a lot of trouble in the future and will generally make the Internet experience better.</p>
<p>I recently had a read of the <a href="http://html5doctor.com">HTML 5 doctor</a> blog and am excited to see what's going on. However, reading the <a href="http://html5doctor.com/measure-up-with-the-meter-tag/">Measure up with the meter tag</a> article, my brain did a backflip and my mouth said &quot;Wuh?! How'd they do that?&quot;</p>
<p>I'm refering to a specific part of the article where author Tom Leadbetter shows off some meter tags and the JustGiving web site saying &quot;we could use meter here&quot; (linked image below)</p>
<p><img src="https://html5doctor.com/wp-content/uploads/2009/08/just-giving-example.jpg" alt="" title="HTML 5 Just Giving example" loading="lazy"></p>
<p>He also shows the code that goes below it, reproduced and corrected for the example here:</p>
<dl> <dt>Target</dt> <dd><meter min="245" value="245" title="pounds">245</meter></dd> <dt>Amount raised so far</dt> <dd><meter min="0" max="250" value="185" title="pounds">185</meter></dd> </dl>
<p>What I was thinking at this point was, <em><strong>&quot;how on earth is that possible using those tags? Surely that's not posssible.&quot;</strong></em> So, I set about trying to prove that it was possible...</p>
<p><strong>It's not</strong></p>
<p><a href="http://download.steveworkman.com/meter.html">See my attempt to style the meter tag.</a> (works in Opera, Firefox and Safari)</p>
<p><a href="/static/img/styling-meter.png"><img src="/static/img/styling-meter.png" alt="" title="Styling the meter tag" loading="lazy"></a></p>
<p>The fundamental issue is that using CSS and HTML5 alone, you do not have access to values of attributes that you can use again to set CSS properties. My main issue is that this is trivial in javascript, as demonstrated on the demo page.</p>
<p>There are some potential CSS modules that can help in this respect, namely <a href="http://disruptive-innovations.com/zoo/cssvariables/">CSS Variables</a> and <a href="http://kilianvalkhof.com/2006/css-xhtml/random-css-thought-math-in-css/">CSS Math</a>. I am also oblivious to the power of canvas and SVG, so if anyone can give me an answer using those I'd be very pleased.</p>
<p>I like the idea of HTML 5 but actually styling these new elements is going to be a real challenge. So, community at large, how do you solve this one?</p>
<p><strong>Update:</strong> I <a href="http://lists.w3.org/Archives/Public/www-style/2009Oct/0100.html">submitted this to the W3 CSS Working Group</a> and got some very good responses. Principally, as Bruce commented, I should be using the <a href="http://www.w3.org/TR/css3-values/#attribute">CSS3 Values attr()</a> element to access values of properties and do the math, then use the <a href="http://www.w3.org/TR/css3-content/">generated content</a> module to put the graphic in the right place. Their main concern is that you'd have to use &quot;s/#meter::after/#meter::after::after&quot; as a selector, which isn't supported by anything right now, and background clipping is a bit dodgy too.</p>
<p>Brad Kemper <a href="http://www.bradclicks.com/cssplay/guage.html">did a quick mock-up</a> which will work on webkit nightlies. I would update my <a href="http://download.steveworkman.com/meter.html">demo</a> to show what the CSS WG guys were doing, but nothing works, it's all theory at the moment. Lets hope for more soon.</p>


  
    <p>
    
        <a href="/tags/HTML5/" rel="tag">HTML5</a>
    </p>
  

</article>

<nav>
  <a href="/">Back to home</a>
</nav>

		</main>

		<aside>
			<h2>Find me online</h2>
<ul>
    <li><a href="https://webperf.social/steveworkman" target="_blank">Mastodon - @steveworkman@webperf.social</a></li>
    <li><a href="https://www.threads.net/@steveworkagram" target="_blank">Threads - @steveworkagram</a></li>
    <li><a href="https://www.instagram.com/steveworkagram/" target="_blank">Instagram</a></li>
    <li><a href="https://www.github.com/steveworkman/" target="_blank">Github - steveworkman</a></li>
</ul>
<h2>Posts in other categories</h2>
<ul class="taglist">

    
    <li><a href="/tags/Browsers/" class="tag">Browsers (10)</a></li>

    
    <li><a href="/tags/Conferences/" class="tag">Conferences (1)</a></li>

    
    <li><a href="/tags/CSS3/" class="tag">CSS3 (14)</a></li>

    
    <li><a href="/tags/Facebook/" class="tag">Facebook (3)</a></li>

    
    <li><a href="/tags/Genesys/" class="tag">Genesys (1)</a></li>

    
    <li><a href="/tags/Gigs/" class="tag">Gigs (1)</a></li>

    
    <li><a href="/tags/Google Wave/" class="tag">Google Wave (1)</a></li>

    
    <li><a href="/tags/Hiring/" class="tag">Hiring (2)</a></li>

    
    <li><a href="/tags/HTML5/" class="tag">HTML5 (20)</a></li>

    
    <li><a href="/tags/Interviewing/" class="tag">Interviewing (1)</a></li>

    
    <li><a href="/tags/iPhone/" class="tag">iPhone (12)</a></li>

    
    <li><a href="/tags/JavaScript/" class="tag">JavaScript (14)</a></li>

    
    <li><a href="/tags/Learning/" class="tag">Learning (1)</a></li>

    
    <li><a href="/tags/Microsoft/" class="tag">Microsoft (10)</a></li>

    
    <li><a href="/tags/Mobile/" class="tag">Mobile (12)</a></li>

    
    <li><a href="/tags/Node.js/" class="tag">Node.js (1)</a></li>

    
    <li><a href="/tags/Off-topic/" class="tag">Off-topic (11)</a></li>

    
    <li><a href="/tags/Performance/" class="tag">Performance (5)</a></li>

    
    <li><a href="/tags/Projects/" class="tag">Projects (2)</a></li>

    
    <li><a href="/tags/Rails/" class="tag">Rails (2)</a></li>

    
    <li><a href="/tags/Ramblings/" class="tag">Ramblings (20)</a></li>

    
    <li><a href="/tags/Reading List/" class="tag">Reading List (1)</a></li>

    
    <li><a href="/tags/Sketchnotes/" class="tag">Sketchnotes (19)</a></li>

    
    <li><a href="/tags/Speaking/" class="tag">Speaking (7)</a></li>

    
    <li><a href="/tags/Steel-Software/" class="tag">Steel-Software (2)</a></li>

    
    <li><a href="/tags/Usability/" class="tag">Usability (9)</a></li>

    
    <li><a href="/tags/USE/" class="tag">USE (16)</a></li>

    
    <li><a href="/tags/User Experience/" class="tag">User Experience (11)</a></li>

    
    <li><a href="/tags/User Interfaces/" class="tag">User Interfaces (10)</a></li>

    
    <li><a href="/tags/Web Design/" class="tag">Web Design (12)</a></li>

    
    <li><a href="/tags/Web Standards/" class="tag">Web Standards (33)</a></li>

</ul>
		</aside>

		<footer>
  <small>
    This content is &copy; 2003-2023 Steve Workman and does not necessarily represent the views, strategies or opinions of my employer.<br>
    This blog is made with <a href="https://www.11ty.io/">Eleventy</a>.
  </small>
</footer>


	</body>

</html>