<?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>Thoughts From Eric</title>
	<atom:link href="http://meyerweb.com/index.php?feed=rss2&#038;scope=summary" rel="self" type="application/rss+xml" />
	<link>http://meyerweb.com/eric/thoughts</link>
	<description>Things that Eric A. Meyer, CSS expert, writes about on his personal Web site; it&#039;s largely Web standards and Web technology, but also various bits of culture, politics, personal observations, and other miscellaneous stuff</description>
	<lastBuildDate>Fri, 25 May 2012 13:41:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>A Precise CSS3 Color Table</title>
		<link>http://meyerweb.com/eric/thoughts/2012/05/18/aprecise-css3-color-table/</link>
		<comments>http://meyerweb.com/eric/thoughts/2012/05/18/aprecise-css3-color-table/#comments</comments>
		<pubDate>Fri, 18 May 2012 20:26:02 +0000</pubDate>
		<dc:creator>Eric Meyer</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://meyerweb.com/eric/thoughts/?p=1863</guid>
		<description><![CDATA[I couldn’t find the exact table of CSS colors that I wanted, so I created my own.  (Now with sorting!)]]></description>
			<content:encoded><![CDATA[<p>In the course of expanding my documentation of color values, I failed to find a table that listed all 147 SVG-and-CSS3-defined keywords along with the equivalent RGB decimal, RGB percent, HSL, hexadecimal, and (when valid) short-hex values.  There were some tables that listed some but not all of those value types, and one that listed all the value types (plus CMYK) along with a few hundred other keywords, but none that listed all of the CSS keywords and value types.  And none that I saw used precise values for the RGB percent and HSL types, preferring instead to round off at the expense of some subtle differences in color.</p>

<p>So I <a href="http://meyerweb.com/eric/css/colors/">created my own table, which you can now find</a> in <a href="http://meyerweb.com/eric/css/">the CSS area of meyerweb</a>.  Most of it is dynamically generated, taking a list of keywords and RGB decimal equivalents and then calculating the rest of the values from there.  The presentation is still a work in progress, and may change a little or a lot.  In particular, if I can’t find a better algorithm for determining which rows should have white text instead of black, I’ll probably shift away from the full-row background colors to some other presentation.  <ins>(Update: it’s been greatly improved, so I’m sticking with the full-row backgrounds.  For now, anyway.)</ins></p>

<p>My thanks to <a href="http://www.xanthir.com/">Tab Atkins</a> for his donation of the RGB-to-HSL routine I adapted as well as help improving the pick-light-or-dark-text algorithm; and to the people who responded positively on Twitter when I mused about the idea there.</p>

<p><strong>Update 25 May 12:</strong> the table now allows sorting (both directions) on the Keyword, RGB Decimal, and HSL columns.  The sorting and styling code uses methods like <code>el.classList.remove()</code> so it may not function well, or at all, in older versions of Internet Explorer.  The numeric sorts also appear to be borked in Opera and Chrome for no reason I can discern, and it’s not like I did anything fancy in the JavaScript—exactly the opposite, I’d wager.  (Speaking of which, I’m sure my JavaScript is an non-stop amateur-hour horrorshow.  I’m okay with that.  If you aren’t, you might want to avert your gaze.)  If there’s a simple fix that doesn’t screw up other browsers, like Safari and Firefox, I’m interested.  If not, then we’ll all just have to live with it.</p>

<p>As always: share and enjoy!</p>]]></content:encoded>
			<wfw:commentRss>http://meyerweb.com/eric/thoughts/2012/05/18/aprecise-css3-color-table/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Backgrounds, Shadows, Fonts, and the Cascade</title>
		<link>http://meyerweb.com/eric/thoughts/2012/05/16/background-shadows-fonts-and-the-cascade/</link>
		<comments>http://meyerweb.com/eric/thoughts/2012/05/16/background-shadows-fonts-and-the-cascade/#comments</comments>
		<pubDate>Wed, 16 May 2012 14:11:57 +0000</pubDate>
		<dc:creator>Eric Meyer</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://meyerweb.com/eric/thoughts/?p=1851</guid>
		<description><![CDATA[In the cascade, all other things being equal, the last one declared is the winner.  In backgrounds and shadows, the reverse is true.]]></description>
			<content:encoded><![CDATA[<p>The fact that this:</p>

<pre><code>h1 {color: red;}
h1 {color: green;}
</code></pre>

<p>…results in green <code>h1</code> text, but this:</p>

<pre><code>h1 {background:
	url(red-wave.gif) repeat,
	url(green-wave.gif) repeat;}
</code></pre>

<p>…results in a red wavy <code>h1</code> background does my head in <strong>every single time</strong>.  And it’s the same with text and box shadows, too!  In cases where backgrounds or shadows overlap, the <em>first</em> one you write “wins”, by virtue of being “in front of” the background images that are listed after it.</p>

<p>I know that font stacks are also done in order of most-to-least preferred, but I don’t see them as being equivalent.  The reason is that a font stack is a list of fallbacks—use this face unless it can’t render the glyph or doesn’t exist, in which case try the next one in the list, etc., etc.  Multiple background images and multiple shadows, on the other hand, are <strong>not</strong> a series of fallbacks.  I expect to see them all, unless I made a mistake of some kind; and I do, constantly, because of this disconnect.  Sure, one <em>could</em> use the multiple background image syntax to create a series of fallbacks—first an SVG file, second a PNG, third a GIF—but that’s not its primary purpose, and I certainly wouldn’t teach multiple background images that way.  That’s not what they’re designed to do.</p>

<p>Maybe writing the problem down here will purge this daemon, but in all honesty, my hopes are not terribly high.</p>]]></content:encoded>
			<wfw:commentRss>http://meyerweb.com/eric/thoughts/2012/05/16/background-shadows-fonts-and-the-cascade/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Defining ‘ch’</title>
		<link>http://meyerweb.com/eric/thoughts/2012/05/15/defining-ch/</link>
		<comments>http://meyerweb.com/eric/thoughts/2012/05/15/defining-ch/#comments</comments>
		<pubDate>Tue, 15 May 2012 13:37:03 +0000</pubDate>
		<dc:creator>Eric Meyer</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Standards]]></category>

		<guid isPermaLink="false">http://meyerweb.com/eric/thoughts/?p=1838</guid>
		<description><![CDATA[I’m working my way through a rewrite of Two Salmon (more on that anon), and I just recently came to the <code>ch</code> unit.]]></description>
			<content:encoded><![CDATA[<p>I’m working my way through a rewrite of Two Salmon (more on that anon), and I just recently came to the <code>ch</code> unit.  Its definition in <a href="http://w3.org/TR/2012/WD-css3-values-20120308/">the latest CSS Values and Units module</a> is as follows:</p>

<blockquote cite="http://w3.org/TR/2012/WD-css3-values-20120308/#ch-unit">
<dl>
<dt><dfn id=ch-unit title=ch>ch unit</dfn></dt>
<dd><p>Equal to the advance measure of the &#8220;0&#8243; (ZERO, U+0030) glyph found in the font used to render it.</p></dd>
</dl>
</blockquote>

<p>…and that’s it.  I had never heard the term “advance measure” before, and a bit of Googling for <kbd>font "advance measure"</kbd> only led me to copies of the CSS Values and Units module and some configuration files for <a href="https://www.panda3d.org/">the Panda 3D game engine</a>.  So I asked the editor and it turns out that “advance measure” is a CSS-ism that corresponds to the term “advance width”, which I had also never heard before but which yielded <em>way</em> more Google results.  Wikipedia’s <a href="http://en.wikipedia.org/wiki/Font">entry for “Font”</a> has this definition:</p>

<blockquote cite="http://en.wikipedia.org/wiki/Font#Metrics">
<p>Glyph-level metrics include … the advance width (the proper distance between the glyph&#8217;s initial pen position and the next glyph&#8217;s initial pen position)…</p>
</blockquote>

<p>My question for the font geeks in the room is this:  is that the generally accepted definition for “advance width”?  If not, is there a better definition out there; and if so, where?  I’d like to be able to recommend the best known definition for inclusion in the specification; or, if there’s no agreement as to the best, then at least a good one.  The Wikipedia definition certainly sounds good, assuming it’s accurate.  Is it?</p>

<p>In CSS terms, if I’ve understood things correctly, <code>1ch</code> is equal to the width of the character box for the glyph for “0”.  In other words, if I were to create a floated element with just a “0” and no whitespace between it and the element’s open and close tags, then the float’s width would be precisely <code>1ch</code>.  But that’s if I’ve understood things correctly.  If I haven’t, I hope I’ll be corrected soon!</p>]]></content:encoded>
			<wfw:commentRss>http://meyerweb.com/eric/thoughts/2012/05/15/defining-ch/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Vendor Tokens</title>
		<link>http://meyerweb.com/eric/thoughts/2012/05/08/vendor-tokens/</link>
		<comments>http://meyerweb.com/eric/thoughts/2012/05/08/vendor-tokens/#comments</comments>
		<pubDate>Tue, 08 May 2012 17:55:02 +0000</pubDate>
		<dc:creator>Eric Meyer</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://meyerweb.com/eric/thoughts/?p=1832</guid>
		<description><![CDATA[It may be that from the ashes of vendor prefixes will arise a new way forward.]]></description>
			<content:encoded><![CDATA[<p>It may be that from the ashes of vendor prefixes will arise a new way forward.  As <a href="http://lists.w3.org/Archives/Public/www-style/2012Apr/0797.html">proposed by François Remy</a>, vendor tokens would serve the same basic purpose as prefixes with a different syntactical approach, and with at east a couple of extra benefits.  Instead of prefixing properties, you’d instead add vendor tokens to the end of a single declaration, much as you do <code>!important</code> (which of course we <em>never ever</em> use, amirite?).</p>

<p>For example, you might write:</p>

<pre><code>border-radius: 1em !webkit-draft !moz-draft !o-draft;</code></pre>

<p>That’s it.  The prefixed alternative, of course, runs to multiple lines and has spawned a whole subindustry of framework plugins and mixins and what-all just to take the repetitive authoring burden off our shoulders.</p>

<p>I’ve been contemplating this proposal all morning, and perhaps not too surprisingly I’ve come down in favor of the idea.  I’m <a href="http://alistapart.com/articles/prefix-or-posthack">on record as being a fan of vendor prefixes</a>, but what I was truly a fan of was the capabilities they offer.  The syntax was never a core interest for me, and the ugliness was pretty apparent.  Vendor tokens are less tortuous, and even make it much simpler to build in versioning, like so:</p>

<pre><code>border-radius: 1em !webkit-draft-2 !moz-draft !o-draft;</code></pre>

<p>Not that I’m saying this proposal will or even should get to that point, but the ability is there and it feels cleaner than trying to do the same thing with prefixes.  I feel they ought to drop the <code>-draft</code> part of the tokens; just saying <code>!webkit !moz !o</code> or possibly <code>!x-webkit !x-moz !x-o</code> should be sufficient.  I’m also not a fan of the bang, but then I never have been, and I figure any token marker would suffice.  As before, it’s not the syntax I care about so much as the capabilities.</p>

<p>There is a discussion ongoing at <a href="http://lists.w3.org/Archives/Public/www-style/">www-style</a>, if you’re interested in adding your perspective or even just following along as various stakeholders thrash at the idea.  I’m cautiously optimistic.  It’s kind of a nice feeling!</p>]]></content:encoded>
			<wfw:commentRss>http://meyerweb.com/eric/thoughts/2012/05/08/vendor-tokens/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Plugging Up</title>
		<link>http://meyerweb.com/eric/thoughts/2012/04/27/plugging-up/</link>
		<comments>http://meyerweb.com/eric/thoughts/2012/04/27/plugging-up/#comments</comments>
		<pubDate>Fri, 27 Apr 2012 14:02:13 +0000</pubDate>
		<dc:creator>Eric Meyer</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Parenting]]></category>

		<guid isPermaLink="false">http://meyerweb.com/eric/thoughts/?p=1724</guid>
		<description><![CDATA[I get asked from time to time for my number one tip for new parents. My answer is always a single word. “Earplugs.” Seriously. Get some earplugs. They don’t have to be fancy; the squishy yellow foam plugs you can get in a cardboard holder for a dollar work just fine. If you already have [...]]]></description>
			<content:encoded><![CDATA[<p>I get asked from time to time for my number one tip for new parents.  My answer is always a single word.</p>

<p>“Earplugs.”</p>

<p>Seriously.  Get some earplugs.  They don’t have to be fancy; the squishy yellow foam plugs you can get in a cardboard holder for a dollar work just fine.  If you already have some fancier in-ear jobs for rock concerts or woodworking or whatever, those are good too.</p>

<p>Because as much as you love your new baby, and as much as you will work to keep them calm and happy, there will almost certainly be times when they are hurting or uncomfortable or just generally upset and unable to be soothed.  No matter how much you cuddle and sing and swaddle, they will scream and cry.  Some kids will do this rarely.  Others will do it all the time.  (A friend of ours tells how her eldest child screamed more or less non-stop from the day she was born until the day she walked.)  I don’t honestly know which is harder to handle, but I do know that the screaming worked its way through my eardrums and into my brain to induce a panicked pseudo-flight-or-flight response.  It was cumulatively, enormously stressful.</p>

<p>Earplugs do not shut out the cries completely.  You will not be denying your baby’s distress or placing unwarranted distance between you and your child.  Earplugs simply take the raw, serrated edge off their cry, giving you some mental space to cope with it and be a calmer and therefore better parent.  It lets you hang in there longer, putting off the point where you have to put the baby in the crib and walk away for a few minutes.  (And that’s okay too; the baby won’t die if you take five to regroup.)  That means more direct contact with your baby, and possibly a shorter time to a calm baby due to longer, more continuous periods of parental contact.</p>

<p>So: earplugs.  Probably the highest-ROI parental purchase I ever made.</p>]]></content:encoded>
			<wfw:commentRss>http://meyerweb.com/eric/thoughts/2012/04/27/plugging-up/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Linear Gradient Keywords</title>
		<link>http://meyerweb.com/eric/thoughts/2012/04/26/lineargradient-keywords/</link>
		<comments>http://meyerweb.com/eric/thoughts/2012/04/26/lineargradient-keywords/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 18:54:52 +0000</pubDate>
		<dc:creator>Eric Meyer</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Standards]]></category>

		<guid isPermaLink="false">http://meyerweb.com/eric/thoughts/?p=1800</guid>
		<description><![CDATA[Linear gradients in CSS can lead to all kinds of wacky, wacky results—some of them, it sometimes seems, in the syntax itself.]]></description>
			<content:encoded><![CDATA[<p>Linear gradients in CSS can lead to all kinds of wacky, wacky results—some of them, it sometimes seems, in the syntax itself.</p>

<p>Let me note right up front that some of what I’m talking about here isn’t widely deployed yet, nor for that matter even truly set in stone.  Close, maybe, but there could still be changes.  Even if nothing actually does change, this isn’t a “news you can use <strong>RIGHT NOW</strong>” article.  Like so much of what I produce, it’s more of a stroll through a small corner of CSS, just to see what we might see.</p>

<p>For all their apparent complexity, linear gradients are pretty simple.  You define a direction along which the gradient progresses, and then list as many color stops as you like.  In doing so, you describe an image with text, sort of like SVG does.  That’s an important point to keep in mind:  a linear (or radial) gradient is an image, just as much as any GIF or PNG.  That means, among other things, that you can mix raster images and gradient images in the background of an element using the multiple background syntax.</p>

<p>But back to gradients.  Here’s a very simple gradient image:</p>

<pre><code>linear-gradient(45deg, red, blue)</code></pre>

<p>The <code>45deg</code> defines the <em>gradient line</em>, which is the line that defines how the gradient progresses.  The gradient line <strong>always</strong> passes through the center of the background area, and its specific direction is declared by you, the author.  In this case, it’s been declared to point toward the 45-degree angle.  <code>red</code> and <code>blue</code> are the color stops.  Since the colors don’t have stop distances defined, the distances are assumed to be <code>0%</code> and <code>100%</code>, respectively, which means you get a gradient blend from red to blue that progresses along the gradient line.</p>

<p>You can create hard stops, too:</p>

<pre><code>linear-gradient(45deg, green 50%, lightblue 50%)</code></pre>

<img src="http://meyerweb.com/pix/2012/04gradients01.gif" alt="Figure 1" class="pic" />

<p>That gets you the result shown in Figure 1, to which I’ve added (in Photoshop) an arrow showing the direction of the gradient line, as well as the centerpoint of the background area.  Each individual “stripe” in the gradient is perpendicular to the gradient line; that’s why the boundary between the two colors at the 50% point is perpendicular to the gradient line.  This perpendicularness is <em>always</em> the case.</p>

<p>Now, degrees are cool and all (and they’ll be changing from math angles to compass angles in order to harmonize with animations, but that’s a subject for another time), but you can also use directional keywords.  Two different kinds, as it happens.</p>

<p>The first way to use keywords is to just declare a direction, mixing and matching from the terms <code>top</code>, <code>bottom</code>, <code>right</code>, and <code>left</code>.  The funky part is that in this case, you’re declaring the direction the gradient line comes <em>from</em>, not that toward which it’s going; that is, you specify its origin instead of its destination.  So if you want your gradient to progress from the bottom left corner to the top right corner, you actually say <code>bottom left</code>:</p>

<pre><code>linear-gradient(bottom left, green 50%, lightblue 50%)</code></pre>

<img src="http://meyerweb.com/pix/2012/04gradients02.gif" alt="Figure 2" class="pic" />

<p>But <code>bottom left</code> does not equal <code>45deg</code>, unless the background area is exactly square.  If the area is not square, then the gradient line goes from one corner to another, with the boundary lines perpendicular to that, as shown in Figure 2.  Again, I added a gradient line and centerpoint in Photoshop for clarity.</p>

<p>Of course, this means that if the background area resizes in either direction, then the angle of the gradient line will also change.  Make the element taller or more narrow, and the line will rotate counter-clockwise (UK: anti-clockwise); go shorter or wider and it will rotate clockwise (UK: clockwise).  This might well be exactly what you want.  It’s certainly different than an degree angle value, which will never rotate due to changes in the background’s size.</p>

<p>The second way to use keywords looks similar, but has quite different results.  You use the same top/bottom/left/right terms, but in addition you prepend the <code>to</code> keyword, like so:</p>

<pre><code>linear-gradient(to top right, green 50%, lightblue 50%)</code></pre>

<img src="http://meyerweb.com/pix/2012/04gradients03.gif" alt="Figure 3" class="pic" />

<p>In this case, it’s clear that you’re declaring the gradient line’s destination and not its origin; after all, you’re saying <code>to top right</code>.  However, when you do it this way, you are <em>not</em> specifying the top right corner of the background area.  You’re specifying a general topward-and-rightward direction.  You can see the result of the previous sample in Figure 3; once more, Photoshop was used to add the gradient line.</p>

<p>Notice the hard-stop boundary line.  It’s actually stretching from top left to bottom right (neither of which is <code>top right</code>).  That’s because with the <code>to</code> keyword in front, you’re triggering what’s been referred to as “magic corners” behavior.  When you do this, no matter how the background area is (re)sized, that boundary line will always stretch from top left to bottom right.  Those are the magic corners.  The gradient line thus doesn’t point into the top right corner, unless the background area is perfectly square—it points into the top right quadrant (quarter) of the background area.  Apparently the term “magic quadrants” was not considered better than “magic corners”.</p>

<p>The effect of changing the background area’s size is the same as before; decreasing the height or increasing the width of the background area will deflect the gradient line clockwise, and the opposite change to either axis will produce the opposite deflection.  The only difference is the starting condition.</p>

<p>Beyond all this, if you want to use keywords that always point <em>toward</em> a corner, as in Figure 2 except specifying the destination instead of the origin, that doesn’t appear to be an option.  Similarly, neither can you declare an origin quadrant.  Having the gradient line always traverse from corner to corner means declaring the origin of the gradient line (Figure 2).  If you want the “magic corners” effect where the 50% color-stop line points from corner to corner, with the gradient line’s destination flexible, then you declare a destination quadrant (Figure 3).</p>

<p>As for actual support:  as of this writing, only Firefox and Opera support “magic corners”.  All current browsers—in Explorer’s case, that means IE10—support angles and non-magic keywords, which means Opera and Firefox support <em>both</em> keyword behaviors.  Nobody has yet switched from math angles to compass angles.  (I used <code>45deg</code> very intentionally, as it’s the same direction in either system.)</p>

<p>That’s the state of things with linear gradients right now.  I’m interested to know what you think of the various keyword patterns and behaviors—I know I had some initial trouble grasping them, and having rather different effects for the two patterns seems like it will be confusing.  What say you?</p>]]></content:encoded>
			<wfw:commentRss>http://meyerweb.com/eric/thoughts/2012/04/26/lineargradient-keywords/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Firefox Failing localStorage Due to Cookie Policy</title>
		<link>http://meyerweb.com/eric/thoughts/2012/04/25/firefox-failing-localstorage/</link>
		<comments>http://meyerweb.com/eric/thoughts/2012/04/25/firefox-failing-localstorage/#comments</comments>
		<pubDate>Wed, 25 Apr 2012 14:07:07 +0000</pubDate>
		<dc:creator>Eric Meyer</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://meyerweb.com/eric/thoughts/?p=1781</guid>
		<description><![CDATA[I recently stumbled over a subtle interaction between cookie policies and <code>localStorage</code> in Firefox.  Herewith, I document it for anyone who might run into the same problem (all four of you).]]></description>
			<content:encoded><![CDATA[<p>I recently stumbled over a subtle interaction between cookie policies and <code>localStorage</code> in Firefox.  Herewith, I document it for anyone who might run into the same problem (all four of you) as well as for you JS developers who are using, or thinking about using, locally stored data.  Also, there’s <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=748620">a Bugzilla report</a>, so either it’ll get fixed and then this won’t be a problem or else it will get resolved WONTFIX and I’ll have to figure out what to do next.</p>

<p>The basic problem is, every newfangled “try code out for yourself” site I hit is just failing in Firefox 11 and 12.  <a href="http://dabblet.com/">Dabblet</a>, for example, just returns a big blank page with the toolbar across the top, and none of the top-right buttons work except for the Help (“?”) button.  And I write all that in the present tense because the problem still exists as I write this.</p>

<p>What’s happening is that any attempt to access <code>localStorage</code>, whether writing or reading, returns a security error.  Here’s an anonymized example from Firefox’s error console:</p>

<p><code>Error: uncaught exception: [Exception... "Security error"  code: "1000" nsresult: "0x805303e8 (NS_ERROR_DOM_SECURITY_ERR)"  location: "http://example.com/code.js Line: 666"]</code></p>

<p>When you go to line 666, you discover it refers to <code>localStorage</code>.  Usually it’s a write attempt, but reading gets you the same error.</p>

<p>But here’s the thing: it only does this if your browser preferences are set so that, when it comes to accepting cookies, the “Keep until:” option is set to “ask me every time”.  If you change that to either of the other two options, then <code>localStorage</code> can be written and read without incident.  No security errors.  Switch it back to “ask me every time”, and the security errors come back.</p>

<p>Just to cover all the bases regarding my configuration:</p>

<ol>
<li>Firefox is <em>not</em> in Private Browsing mode.</li>
<li><code>dom.storage.default_quota</code> is <code>5120</code>.</li>
<li><code>dom.storage.enabled</code> is <code>true</code>.</li>
</ol>

<p>Also:  yes, I have my cookie policy set that way on purpose.  It might not work for you, but it definitely works for me.  “Just change your cookie policy” is the new “use a different browser” (which is the new “get a better OS”) and it ain’t gonna fly here.</p>

<p>To my way of thinking, this behavior doesn’t conform to step one of <a href="http://w3.org/TR/webstorage/#dom-localstorage"><cite>4.3 The <code>localStorage</code> attribute</cite></a>, which states:</p>

<blockquote cite="http://w3.org/TR/webstorage/#dom-localstorage"><p>The user agent may throw a <code>SecurityError</code> exception instead of returning a <code>Storage</code> object if the request violates a policy decision (e.g. if the user agent is configured to not allow the page to persist data). </p></blockquote>

<p>I haven’t configured anything to not persist data—quite the opposite—and my policy decision is not to refuse cookies, it’s to ask me about expiration times so I can decide how I want a given cookie handled.  It seems to me that, given my current preferences, Firefox ought to ask me if I want to accept local storage of data whenever a script tries to write to <code>localStorage</code>.  If that’s somehow impossible, then there should at least be a global preference for how I want to handle <code>localStorage</code> actions.</p>

<p>Of course, that’s all true only if <code>localStorage</code> data has expiration times.  If it doesn’t, then I’ve already said I’ll accept cookies, even from third-party sites.  I just want a say on their expiration times (or, if I choose, to deny the cookie through the dialog box; it’s an option).  I’m not entirely clear on this, so if someone can point to hard information on whether <code>localStorage</code> does or doesn’t time out, that would be fantastic.  I did see:</p>

<blockquote cite="http://w3.org/TR/webstorage/#dom-localstorage"><p>User agents should expire data from the local storage areas only for security reasons or when requested to do so by the user.</p></blockquote>

<p>…from <a href="http://w3.org/TR/webstorage/#dom-localstorage">the same section</a>, which to me sounds like <code>localStorage</code> doesn’t have expiration times, but maybe there’s another bit I haven’t seen that casts a new light on things.  As always, tender application of the Clue-by-Four of Enlightenment is welcome.</p>

<p>Okay, so the point of all this: if you’re getting <code>localStorage</code> failures in Firefox, check your cookies expiration policy.  If that’s the problem, then at least you know how to fix it—or, as in my case, why you’ll continue to have <code>localStorage</code> problems for the next little while.  Furthermore, if you’re writing JS that interacts with <code>localStorage</code> or a similar local-data technology, <em>please</em> make sure you’re looking for security exceptions and other errors, and planning appropriate fallbacks.</p>]]></content:encoded>
			<wfw:commentRss>http://meyerweb.com/eric/thoughts/2012/04/25/firefox-failing-localstorage/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Boy Howdy!</title>
		<link>http://meyerweb.com/eric/thoughts/2012/04/18/boy-howdy/</link>
		<comments>http://meyerweb.com/eric/thoughts/2012/04/18/boy-howdy/#comments</comments>
		<pubDate>Wed, 18 Apr 2012 14:57:45 +0000</pubDate>
		<dc:creator>Eric Meyer</dc:creator>
				<category><![CDATA[Humor]]></category>

		<guid isPermaLink="false">http://meyerweb.com/eric/thoughts/?p=1771</guid>
		<description><![CDATA[It’s caption contest time!]]></description>
			<content:encoded><![CDATA[<p>
This picture <em>completely cracks me up</em> every time I look at it:
</p>
<p class="standalone">
<img src="http://meyerweb.com/pix/2012/clinton-obama.jpg" alt="" style="max-width: 100%;"/>
</p>
<p>
So guess what?  It’s <strong>caption contest time!</strong>  Give us your best caption(s) in the comments, and see if you have what it takes to boost the inherent hilarity.  Knock us out!
</p>
<p>(Photo credit: <a href="http://www.drewangerer.com/">Drew Angerer</a>/The New York Times.)</p>]]></content:encoded>
			<wfw:commentRss>http://meyerweb.com/eric/thoughts/2012/04/18/boy-howdy/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
		<item>
		<title>Element Customization</title>
		<link>http://meyerweb.com/eric/thoughts/2012/04/10/element-customization/</link>
		<comments>http://meyerweb.com/eric/thoughts/2012/04/10/element-customization/#comments</comments>
		<pubDate>Tue, 10 Apr 2012 20:16:21 +0000</pubDate>
		<dc:creator>Eric Meyer</dc:creator>
				<category><![CDATA[(X)HTML]]></category>
		<category><![CDATA[HTML5]]></category>

		<guid isPermaLink="false">http://meyerweb.com/eric/thoughts/?p=1759</guid>
		<description><![CDATA[A couple of weeks back I wrote about <a href="http://meyerweb.com/eric/thoughts/2012/03/28/customizing-your-markup/">customizing your markup</a>, but I got an important bit wrong and while I’ve corrected the post, I wanted to clear up the error in detail.]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks back I wrote about <a href="http://meyerweb.com/eric/thoughts/2012/03/28/customizing-your-markup/">customizing your markup</a>, but I got an important bit wrong and while I’ve corrected the post, I wanted to clear up the error in detail.</p>

<p>I said that you wrap portions of your document (or the whole thing) in an <code>element</code> element and use the customized element inside.  <strong>This is incorrect</strong>, and actually a very bad idea.  In fact, you define your customized elements using an <code>element</code> element and then use the customized elements later in the document.  Something like this:</p>

<pre><code>&lt;element extends=&quot;h1&quot; name=&quot;x-superh1&quot;&gt;
&lt;/element&gt;

&lt;h1 is=&quot;superh1&quot;&gt;UltraMegaPower!!!&lt;/h1&gt;
&lt;h1&gt;Regular Old Power&lt;/h1&gt;
</code></pre>

<p>The line break inside the <code>element</code> element isn’t required—I just threw it in for clarity.</p>

<p>The <code>element</code> element can optionally contain template markup, but I honestly don’t understand that part of it yet.  I get the general idea, but I haven’t crawled through the specifics long enough to have really internalized all the fiddly bits.  And as we all know by know, the fiddly bits are where understanding lives and dies.  (Also where the Devil hangs out, or so I’ve been told.)</p>

<p>I still firmly believe that all this papers over a much bigger problem, which is the arbitrary barrier to devising and using actual custom elements (as opposed to customized existing elements).  HTML5 already allows you to make up your own bits of language: you can make up any attribute you want as long as your preface the name with <code>data-</code>.  Okay, so that’s a little bit clumsy naming-wise, but the capability is there.  You don’t have to register your attributes, or declare them in a list, or any of that other stuff.  You just make up <code>data-timing</code> or <code>data-proglang</code> or <code>data-sttngcharacter</code> on the spot and off you go.</p>

<p>This is not possible for elements.  You can’t even make up a prefixed element name, whether it’s <code>data-kern</code> or <code>x-kern</code> or even <code>xkern</code> (to avoid the limitation that hyphens aren’t allowed in element names).  You just can’t devise your own elements.  The best you can do is use the <code>element</code> element to sprinkle some semantic dust bunnies on top of elements that already exist.</p>

<aside><p>(Aside in an <code>aside</code>: I’m not sure I’m ever going to get tired of saying “the <code>element</code> element”, but I sure am going to grow weary of typing it.)</p></aside>

<p>Of course, all this “you can’t” and “not possible”&nbsp;applies to the specification.  Browsers will let you feed them any old element name and style it, script it, whatever.  Some say that’s more than enough.  If the browser lets you do it, why let the specification hold you back?  And of course, that’s how most people will approach the situation.</p>

<p>To someone like me, though, who spent years (<em>literal</em> years) explaining to web folk the world over that just because Internet Explorer for Windows let you write <code>width: 12 px</code>, actually writing it was still a bad idea—well, those habits die hard.  Just doing stuff because the browser let you do it is not always a good idea.  In fact, more often than not it’s a bad idea.</p>

<p>None of that really matters, as I say, because people are going to inject their own elements into their markup.  They’ll do it because it’s easier than thinking about the proper element to use, or they’ll do it because no appropriate element yet exists, or for some other reason.  That’s why the HTML5 specification ought to include the ability to do it, so that we have a paved path and defined best practices.  The capability is useful, as the <code>data-</code> attribute feature demonstrates.  If there’s a good, solid technical reason why extending that customization from attributes to elements is not desirable, I’d really like to know what it is.</p>]]></content:encoded>
			<wfw:commentRss>http://meyerweb.com/eric/thoughts/2012/04/10/element-customization/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Whitespace in CSS Calculations</title>
		<link>http://meyerweb.com/eric/thoughts/2012/04/10/whitespace-in-css-calculations/</link>
		<comments>http://meyerweb.com/eric/thoughts/2012/04/10/whitespace-in-css-calculations/#comments</comments>
		<pubDate>Tue, 10 Apr 2012 15:00:12 +0000</pubDate>
		<dc:creator>Eric Meyer</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Standards]]></category>

		<guid isPermaLink="false">http://meyerweb.com/eric/thoughts/?p=1747</guid>
		<description><![CDATA[I’ve been messing around with native calculated values in CSS, and there’s something a bit surprising buried in the value format.]]></description>
			<content:encoded><![CDATA[<p>I’ve been messing around with native calculated values in CSS, and there’s something a bit surprising buried in the value format.  To quote the <a href="http://www.w3.org/TR/css3-values/">CSS3 Values and Units specification</a>:</p>

<blockquote cite="http://www.w3.org/TR/css3-values/#calc"><p>Note that the grammar requires spaces around binary ‘+’ and ‘-’ operators. The ‘*’ and ‘/’ operators do not require spaces.</p></blockquote>

<p>In other words, two out of four calculation operators require whitespace around them, and for the other two it doesn’t matter.  Nothing like consistency, eh?</p>

<p>This is why you see examples like this:</p>

<pre><code>width: calc(100%/3 - 2*1em - 2*1px);</code>
</pre>

<p>That’s actually the minimum number of characters you need to write that particular expression, so far as I can tell.  Given the grammar requirements, you could legitimately rewrite that example like so:</p>

<pre><code>width: calc(100% / 3 - 2 * 1em - 2 * 1px);</code>
</pre>

<p>…but <strong>not</strong> like so:</p>

<pre><code>width: calc(100%/3-2*1em-2*1px);</code>
</pre>

<p>The removal of the spaces around the ‘-’ operators means the whole value is invalid, and will be discarded outright by browsers.</p>

<p>We can of course say that this last example is kind of unreadable and so it’s better to have the spaces in there, but the part that trips me up is the general inconsistency in whitespace requirements.  There are apparently very good reasons, or at least very historical reasons, why the spaces around ‘+’ and ‘-’ are necessary.  In which case, I personally would have required spaces around all the operators, just to keep things consistent.  But maybe that’s just me.</p>

<p>Regardless, this is something to keep in mind as we move forward into an era of wider browser support for <code>calc()</code>.</p>

<p>Oh, and by the way, the specification also says:</p>

<blockquote cite="http://www.w3.org/TR/css3-values/#calc"><p>The ‘calc()’ expression represents the result of the mathematical calculation it contains, using standard operator precedence rules.</p></blockquote>

<p>Unfortunately, the specification doesn’t seem to actually define these “standard operator precedence rules”.  This makes for some interesting ambiguities because, as with most standards, <a href="http://en.wikipedia.org/wiki/Order_of_operations#Mnemonics">there are so many to choose from</a>.  For example, <code>3em / 2 * 3</code> could be “three em divided by two, with the result multiplied by three” (thus 4.5em) or “three em divided by six” (thus 0.5em), depending on whether you privilege multipliers over dividers or vice versa.</p>

<p>I’ve looked around the Values and Units specification but haven’t found any text defining the actual rules of precedence, so I’m going to assume US rules (which would yield 4.5em) unless proven otherwise.  <a href="http://meyerweb.com/eric/css/tests/calc.html">Initial testing</a> seems to bear this out, but not every browser line supports these sorts of expressions yet, so there’s still plenty of time for them to introduce inconsistencies.  If you want to be clear about how you want your operators to be resolved, use parentheses: they trump all.  If you want to be sure <code>3em / 2 * 3</code> resolves to 4.5em, then write it <code>(3em / 2) * 3</code>, or <code>(3em/2)*3</code> if you care to use inconsistent whitespacing.</p>]]></content:encoded>
			<wfw:commentRss>http://meyerweb.com/eric/thoughts/2012/04/10/whitespace-in-css-calculations/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Transiently Damaged PDF Attachments</title>
		<link>http://meyerweb.com/eric/thoughts/2012/04/05/transiently-damaged-pdf-attachments/</link>
		<comments>http://meyerweb.com/eric/thoughts/2012/04/05/transiently-damaged-pdf-attachments/#comments</comments>
		<pubDate>Thu, 05 Apr 2012 21:24:26 +0000</pubDate>
		<dc:creator>Eric Meyer</dc:creator>
				<category><![CDATA[Questions]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://meyerweb.com/eric/thoughts/?p=1732</guid>
		<description><![CDATA[I have this very odd problem that seems to be some combination of PDF, Acrobat, Outlook, Thunderbird, and maybe even IMAP and GMail. I know, right? The problem is that certain PDFs sent to me by a single individual won’t open at first. I’ll get one as an email attachment. I drag the attachment to [...]]]></description>
			<content:encoded><![CDATA[<p>I have this very odd problem that seems to be some combination of PDF, Acrobat, Outlook, Thunderbird, and maybe even IMAP and GMail.  I know, right?</p>

<p>The problem is that certain PDFs sent to me by a single individual won’t open at first.  I’ll get one as an email attachment.  I drag the attachment to a folder in my (Snow Leopard) Finder and double-click it to open.  The error dialog I immediately get from Acrobat Professional is:</p>

<blockquote><p>There was an error opening this document. The file is damaged and could not be repaired.</p></blockquote>

<p>Preview, on the other hand, tells me:</p>

<blockquote><p>The file “<em>[redacted]</em>” could not be opened.  It may be damaged or use a file format that Preview doesn’t recognize.</p></blockquote>

<p>When this happens, I tell the person who sent me the file that The Problem has happened again.  She sends me <em>the exact same file</em> as an attachment.  Literally, she just takes the same file she sent before and drags it onto the new message to send to me again.</p>

<p>And this re-sent file opens without incident.  <em>Every time.</em>  Furthermore, extra re-sends open without incident.  I recently had her send me the same initially damaged file five times, some attached to replies and others to brand-new messages.  All of them opened flawlessly.  The initially damaged file remained damaged.</p>

<p>Furthermore, if I go through the GMail web interface, I can view the initial attached PDF (the one my OS X applications say is damaged) through the GMail UI without trouble.  If I download that attachment to my hard drive, it similarly opens in Acrobat (and Preview) without trouble.</p>

<p>A major indication of damage: that first download is a different size than all the others.  In the most recent instance, the damaged file is 680,302 bytes.  The undamaged files are all 689,188 bytes.  If only I knew why it’s damaged the first time, and not all the others!</p>

<p>So far, I’ve yet to see this happen with PDFs from anyone else, but then I receive very few attached PDFs from people other than this one (our events manager at An Event Apart, who sends and receives PDFs and Office documents like they’re conversational speech—an occupational hazard of her line of work), and it only seems to happen with PDFs of image scans that she’s created.  Other types of PDFs, whether she generated them or not, seem to come through fine; ditto for other file types, like Word documents.  I’d be tempted to blame the scanning software, but again: the exact same file is damaged the first time, and fine on every subsequent re-attachment.</p>

<p>I’ve done some Googling, and found scattered advice on ways clear up corrupted-PDF-attachment problems in Thunderbird.  I’ve followed these pieces of advice, and nothing has helped.  In summary, I have so far:</p>

<ol>
<li>Set <code>mail.server.default.fetch_by_chunks</code> to <code>false</code>.</li>
<li>Set <code>mail.imap.mime_parts_on_demand</code> to <code>false</code>.</li>
<li>Set <code>mail.server.default.mime_parts_on_demand</code> to <code>false</code>.</li>
<li>Tried the Thunderbird extension <a href="http://nic-nac-project.org/~kaosmos/index-en.html#openattach">OPENATTACHMENTBYEXTENSION</a>.  That failed, and so I immediately uninstalled it because handling files by extension alone is just asking to be pwned, regardless of your operating system or personal level of datanoia.  (I wouldn’t have left it installed had it worked; I just wanted to see if it <em>did</em> work as a data point.)</li>
</ol>

<p>Here’s what I know about the various systems in play here:</p>

<ul>
<li>I’m using Thunderbird 11.0.1 on OS X 10.6.8.</li>
<li>The attachments are always sent via Outlook 2010 on Windows 7.</li>
<li>The software used for the scanning is the HP scanning software that was installed with the scanner.  Scans are saved to the hard drive, renamed, and then manually attached to the email.  On resend, the same file is manually attached to the email.</li>
<li>My email account is a GMail IMAP account.</li>
</ul>

<p>So.  Any ideas?</p>]]></content:encoded>
			<wfw:commentRss>http://meyerweb.com/eric/thoughts/2012/04/05/transiently-damaged-pdf-attachments/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Touchy About Faucets</title>
		<link>http://meyerweb.com/eric/thoughts/2012/03/30/touchy-about-faucets/</link>
		<comments>http://meyerweb.com/eric/thoughts/2012/03/30/touchy-about-faucets/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 13:45:21 +0000</pubDate>
		<dc:creator>Eric Meyer</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Guide]]></category>

		<guid isPermaLink="false">http://meyerweb.com/eric/thoughts/?p=1634</guid>
		<description><![CDATA[As part of last year’s renovation, we redid our kitchen, which means a new sink and faucet.  Here are two things we did in that area: one good, the other not so much.]]></description>
			<content:encoded><![CDATA[<p>As part of last year’s renovation, we redid our kitchen, which means a new sink and faucet.  We traded up from an overmount single-bowl sink to an undermount double-bowl sink, both aspects of which we’d long wanted.</p>

<p>There was one thing we had to fight a bit to get, though, which was a garbage disposal for each sink bowl.  The plumber didn’t want to do it on ground of it adding weight to the sink.  Our response was, in effect: “We’ll have the sink remounted in ten years if necessary, but put in two disposals.”  So he did, and we’re really glad.</p>

<img src="http://meyerweb.com/pix/2012/delta-addison1.png" alt="" class="pic" style="margin-bottom: 0;"/>
<img src="http://meyerweb.com/pix/2012/delta-addison2.png" alt="" class="pic" style="margin-top: 0; clear: right;"/>

<p>The replacement faucet, however, does not make us nearly as glad.  We decided to get a touch-activated faucet, settling on a <a href="http://www.deltafaucet.com/kitchen/details/9192t-rb-dst.html">Delta Addison single-handle faucet</a>.  The touch activation was because many are the times we want to wash off hands that have just handled raw meat, and being able to touch-on the faucet with a forearm seemed like a great idea—and it is!  The problem is that nearly the entire faucet body, including the temperature/flow adjustment handle, is touch-sensitive.  The exception is the pull-out head, which is inert.</p>

<p>Thus, if you reach past the faucet and brush it by mistake, the water starts flowing.  This is true even if you bump the base of the faucet, which is annoying when you’re trying to wipe down the countertop around the faucet.  Even worse, changing the temperature or flow rate means using the touch-sensitive handle.  There’s evidently logic built into the faucet that’s meant to prevent the water from cutting off if you adjust the handle, but it only works about half the time.  So sometimes you make an adjustment and the flow cuts off, and sometimes it doesn’t.</p>

<p>Frankly, the inconsistency is more maddening than the unwanted cutoffs.  For example, I’ve developed an expectation that the flow will cut off after I use the handle.  So I’ll adjust and then immediately tap the faucet again so it cuts off and then comes back on tap.  Except if it didn’t cut off, then my tap cuts it off before I can stop the impulse and then I have to tap again.</p>

<p>Of course, any touch-sensitive faucet is a total luxury, and fortunately it’s easy to disable the touch feature—all we have to do is pull the batteries from the battery pack and it becomes a regular faucet.  The drawback there is that there are definitely times when you want to be able to turn on the water flow without smearing whatever’s all over your hands on the faucet.  (And with three kids, one of which is an infant, there are some things you <em>definitely</em> want to avoid smearing.)</p>

<p>The really incredible part is that these problems would be completely solved if only the neck of the faucet were touch-sensitive.  If the base, which is a separate part from the neck, and the adjustment handle were inert, easily 90% of our frustration would just vanish.  We could start the water flow by touching the neck and not worry about weirdness with the adjustment handle or when brushing the base.</p>

<p>If you’re thinking of installing a touch-sensitive faucet, I can’t recommend this one, unless of course a future version of it fixes the problems plaguing this one.  And I have no idea if there’s a better touch faucet on the market; for all I know, they’re all like this.  Definitely do your homework, and if at all possible play with a functioning model before taking the plunge.  The touch feature doesn’t add a ton to the price of the base faucet, but it’s enough to be annoying when you’re seriously considering disabling it.</p>]]></content:encoded>
			<wfw:commentRss>http://meyerweb.com/eric/thoughts/2012/03/30/touchy-about-faucets/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Customizing Your Markup</title>
		<link>http://meyerweb.com/eric/thoughts/2012/03/28/customizing-your-markup/</link>
		<comments>http://meyerweb.com/eric/thoughts/2012/03/28/customizing-your-markup/#comments</comments>
		<pubDate>Wed, 28 Mar 2012 14:55:49 +0000</pubDate>
		<dc:creator>Eric Meyer</dc:creator>
				<category><![CDATA[(X)HTML]]></category>
		<category><![CDATA[Commentary]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Microformats]]></category>
		<category><![CDATA[semantic web]]></category>
		<category><![CDATA[Standards]]></category>

		<guid isPermaLink="false">http://meyerweb.com/eric/thoughts/?p=1713</guid>
		<description><![CDATA[HTML5 allows you (at the moment) to create your own custom elements.  Only, not really.]]></description>
			<content:encoded><![CDATA[<p>So HTML5 allows you (at the moment) to create your own custom elements.  Only, not really.</p>

<p><em>(Ed. note: this post has been corrected since its publication, and <a href="http://meyerweb.com/eric/thoughts/2012/04/10/element-customization/">a followup clarification has been posted</a>.)</em></p>

<p>Suppose you’re creating a super-sweet JavaScript library to improve text presentation—like, say, <a href="http://typebutter.com/">TypeButter</a>—and you need to insert a bunch of elements that won’t accidentally pick up pre-existing CSS.  That rules <code>span</code> right out the door, and anything else would be either a bad semantic match, likely to pick up CSS by mistake, or both.</p>

<p>Assuming you don’t want to spend the hours and lines of code necessary to push ahead with <code>span</code> and a whole lot of dynamic CSS rewriting, the obvious solution is to invent a new element and drop that into place.  If you’re doing kerning, then a <code>kern</code> element makes a lot of sense, right?  Right.  And you can certainly do that in browsers today, as well as years back.  Stuff in a new element, hit it up with some CSS, and you’re done.</p>

<p>Now, how does this fit with the HTML5 specification?  Not at all well.  HTML5 does <em>not</em> allow you to invent new elements and stuff them into your document willy-nilly.  You can’t even do it with a prefix like <code>x-kern</code>, because hyphens aren’t valid characters for element names (unless I read <a href="http://www.w3.org/TR/html5/syntax.html#syntax-tag-name">the rules</a> incorrectly, which is always possible).</p>

<p>No, here’s what you do instead <ins datetime="2012-04-10T18:58:15+00:00">(corrected 10 Apr 12)</ins>:</p>

<ol>
<li><del datetime="2012-04-10T18:58:15+00:00">Wrap your document, or at least the portion of it where you plan to use your custom markup,</del><ins datetime="2012-04-10T18:58:15+00:00">Define the element customization you want</ins> with an <code>element</code> element.  That’s not a typo.</li>
<li>To your <code>element</code> element, add an <code>extends</code> attribute whose value is the HTML5 element you plan to extend.  We’ll use <code>span</code>, but you can extend any element.</li>
<li>Now add a <code>name</code> attribute that names your custom “element” name, like <code>x-kern</code>.</li>
<li>Okay, you’re ready!  Now anywhere you want to add a customized element, drop in the elements named by <code>extends</code> and then supply the <code>name</code> via an <code>is</code> attribute.</li>
</ol>

<p>Did you follow all that?  No?  Okay, maybe this will make it a bit less unclear.  <ins datetime="2012-04-10T18:58:15+00:00">(Note: the following code block was corrected 10 Apr 12.)</ins></p>

<pre><code>&lt;element extends="span" name="x-kern"&gt;&lt;/element&gt;
&lt;h1&gt;
&lt;span is="x-kern" style="…"&gt;A&lt;/span&gt;
&lt;span is="x-kern" style="…"&gt;u&lt;/span&gt;
&lt;span is="x-kern" style="…"&gt;t&lt;/span&gt;
&lt;span is="x-kern" style="…"&gt;u&lt;/span&gt;
mn
&lt;/h1&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
</code></pre>

<p>(Based on markup taken from the <a href="http://typebutter.com/demo/">TypeButter demo page</a>.  I simplified the inline <code>style</code> attributes that TypeButter generates for purposes of clarity.)</p>

<p>So that’s <a href="http://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html#custom-element-section">how you create “custom elements” in HTML5 as of now</a>.  Which is to say, you don’t.  All you’re doing is attaching a label to an existing element; you’re sort of customizing an existing element, not creating a customized element.  That’s not going to help prevent CSS from being mistakenly applied to those elements.</p>

<p>Personally, I find this a really, really, <em>really</em> clumsy approach—so clumsy that I don’t think I could recommend its use.  Given that browsers will accept, render, and style arbitrary elements, I’d pretty much say to just go ahead and do it.  Do try to name your elements so they won’t run into problems later, such as prefixing them with an “x” or your username or something, but since browsers support it, may as well capitalize on their capabilities.</p>

<p>I’m not in the habit of saying that sort of thing lightly, either.  While I’m not the wild-eyed standards-or-be-damned radical some people think I am, I have always striven to play within the rules when possible.  Yes, there are always situations where you work counter to general best practices or even the rules, but I rarely do so lightly.  As an example, my co-founders and I went to some effort to play nice when we created the principles for <a href="http://microformats.org/">Microformats</a>, segregating our semantics into attribute values—but only because <a href="http://tantek.com/" rel="friend colleague muse met">Tantek</a>, <a href="http://ma.tt/" rel="friend met">Matt</a>, and I cared a <em>lot</em> about long-term stability and validation.  We went as far as necessary to play nice, and not one millimeter further, and all the while we wished mightily for the ability to create custom attributes and elements.</p>

<p>Most people aren’t going to exert that much effort: they’re going to see that something works and never stop to question if what they’re doing is valid or has long-term stability.  “If the browser let me do it, it must be okay” is the background assumption that runs through our profession, and why wouldn’t it?  It’s an entirely understandable assumption to make.</p>

<p>We need something better.  My personal preference would be to expand the “<a href="http://www.w3.org/TR/html5/syntax.html#foreign-elements">foreign elements</a>” definition to encompass any unrecognized element, and let the parser deal with any structural problems like lack of well-formedness.  Perhaps also expand the rules about element names to permit hyphens, so that we could do things like <code>x-kern</code> or <code>emeyer-disambiguate</code> or whatever.  I could even see my way clear to defining an way to let an author list their customized elements.  Say, something like <code>&lt;meta name=&quot;custom-elements&quot; content=&quot;kern lead follow embiggen shrink&quot;/&gt;</code>.  I just made that up off the top of my head, so feel free to ignore the syntax if it’s too limiting. The general concept is what’s important.</p>

<p>The creation of customized elements isn’t a common use case, but it’s an incredibly valuable ability, and people are going to do it.  They’re <em>already</em> doing it, in fact.  It’s important to figure out how to make the process of doing so simpler and more elegant.</p>]]></content:encoded>
			<wfw:commentRss>http://meyerweb.com/eric/thoughts/2012/03/28/customizing-your-markup/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Invented Elements</title>
		<link>http://meyerweb.com/eric/thoughts/2012/03/23/invented-elements/</link>
		<comments>http://meyerweb.com/eric/thoughts/2012/03/23/invented-elements/#comments</comments>
		<pubDate>Fri, 23 Mar 2012 14:16:58 +0000</pubDate>
		<dc:creator>Eric Meyer</dc:creator>
				<category><![CDATA[(X)HTML]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://meyerweb.com/eric/thoughts/?p=1703</guid>
		<description><![CDATA[This morning I caught <a href="https://twitter.com/#!/fontdeck/status/183176353347153920">a pointer</a> to <a href="http://typebutter.com/">TypeButter</a>, and I’m very interested by how TypeButter accomplishes its kerning.]]></description>
			<content:encoded><![CDATA[<p>This morning I caught <a href="https://twitter.com/#!/fontdeck/status/183176353347153920">a pointer</a> to <a href="http://typebutter.com/">TypeButter</a>, which is a jQuery library that does “optical kerning” in an attempt to improve the appearance of type.  I’m not going to get into its design utility because I’m not qualified; I only notice kerning either when it’s set insanely wide or when it crosses over into <a href="http://www.ironicsans.com/2008/02/idea_a_new_typography_term.html">keming</a>.  I suppose I’ve been looking at web type for so many years, it looks normal to me now.  (Well, <em>almost</em> normal, but I’m not going to get into my personal typographic idiosyncrasies now.)</p>

<p>My reason to bring this up is that I’m very interested by how TypeButter accomplishes its kerning: it inserts <code>kern</code> elements with inline <code>style</code> attributes that bear <code>letter-spacing</code> values.  Not <code>span</code> elements, <code>kern</code> elements.  No, you didn’t miss an HTML5 news bite; there is no <code>kern</code> element, nor am I aware of a plan for one.  TypeButter basically invents a specific-purpose element.</p>

<p>I believe I understand the reasoning.  Had they used <code>span</code>, they would’ve likely tripped over existing author styles that apply to <code>span</code>.  Browsers these days don’t really have a problem accepting and styling arbitrary elements, and any that do would simply render type their usual way.  Because the markup is script-generated, markup validation services don’t throw conniption fits.  There might well be browser performance problems, particularly if you <a href="http://cdn.memegenerator.net/instances/400x/17134306.jpg">optically kern <strong>all</strong> the things</a>, but used in moderation (say, on headings) I wouldn’t expect too much of a hit.</p>

<p>The one potential drawback I can see, as <a href="https://twitter.com/#!/jaffathecake/status/183183488550318080">articulated by Jake Archibald</a>, is the possibility of a future <code>kern</code> element that might have different effects, or at least be styled by future author CSS and thus get picked up by TypeButter’s <code>kern</code>s.  The currently accepted way to avoid that sort of problem is to prefix with <code>x-</code>, as in <code>x-kern</code>.  Personally, I find it deeply unlikely that there will ever be an official <code>kern</code> element; it’s too presentationally focused.  But, of course, one never knows.</p>

<p>If TypeButter shifted to generating <code>x-kern</code> before reaching v1.0 final, I doubt it would degrade the TypeButter experience at all, and it would indeed be more future-proof.  It’s likely worth doing, if only to set a good example for libraries to follow, unless of course there’s downside I haven’t thought of yet.  It’s definitely worth discussing, because as more browser enhancements are written, this sort of issue will come up more and more.  Settling on some community best practices could save us some trouble down the road.</p>

<p><strong>Update 23 Mar 12:</strong> it turns out custom elements are not as simple as we might prefer; see <a href="http://meyerweb.com/eric/thoughts/2012/03/23/invented-elements/?#comment-653402">the comment below</a> for details.  That throws a fairly large wrench into the gears, and requires further contemplation.</p>]]></content:encoded>
			<wfw:commentRss>http://meyerweb.com/eric/thoughts/2012/03/23/invented-elements/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Negative Proximity</title>
		<link>http://meyerweb.com/eric/thoughts/2012/03/07/negative-proximity/</link>
		<comments>http://meyerweb.com/eric/thoughts/2012/03/07/negative-proximity/#comments</comments>
		<pubDate>Wed, 07 Mar 2012 16:00:37 +0000</pubDate>
		<dc:creator>Eric Meyer</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://meyerweb.com/eric/thoughts/?p=1691</guid>
		<description><![CDATA[There’s a subtle aspect of CSS descendant selectors that most people won’t have noticed because it rarely comes up.]]></description>
			<content:encoded><![CDATA[<p>There’s a subtle aspect of CSS descendant selectors that most people won’t have noticed because it rarely comes up: selectors have no notion of element proximity.  Here’s the classic demonstration of this principle:</p>

<pre>body h1 {color: red;}
html h1 {color: green;}</pre>

<p>Given those styles, all <code>h1</code> elements will be green, not red.  That’s because the selectors have equal specificity, so the last one wins.  The fact that the <code>body</code> element is “closer to” the <code>h1</code> than the <code>html</code> element in the document tree is irrelevant.  CSS has no mechanism for measuring proximity within the tree, and if I had to place a bet on the topic I’d bet that it never will.</p>

<p>I bring this up because it can get you into trouble when you’re using <a href="http://www.w3.org/TR/css3-selectors/#negation">the negation pseudo-class</a>.  Consider:</p>

<pre>div:not(.one) p {font-weight: bold;}
div.one p {font-weight: normal;}

&lt;div class="one"&gt;
  &lt;div class="two"&gt;
    &lt;p&gt;Hi there!&lt;/p&gt;
  &lt;/div&gt;
&lt;/div&gt;
</pre>

<p>Given these styles, the paragraph will <em>not</em> be boldfaced.  That’s because both rules match, so the last one wins.  The paragraph will be normal-weight.</p>

<p>“AHA!” you cry.  “But the first rule has a higher specificity, so it wins regardless of the order they’re written in!”  You’d think so, wouldn’t you?  But it turns out that the negation pseudo-class isn’t counted as a pseudo-class.  It, like the univseral selector, doesn’t contribute to specificity at all:</p>

<blockquote cite="http://w3.org/TR/css3-selectors/#specificity"><p>Selectors inside the negation pseudo-class are counted like any other, but the negation itself does not count as a pseudo-class.</p></blockquote>
<p class="quoteattrib">—Selectors Level 3, section 9: <a href="http://w3.org/TR/css3-selectors/#specificity">Calculating a selector’s specificity</a></p>

<p>If you swapped the order of the rules, you’d get a boldfaced paragraph thanks to the “all-other-things-being-equal-the-last-rule-wins” step in the cascade.  However, that wouldn’t keep you from getting a red-on-red paragraph in this case:</p>

<pre>div:not(.one) p {color: red;}
div.one p {background: red;}

&lt;div class="one"&gt;
  &lt;div class="two"&gt;
    &lt;p&gt;Hi there!&lt;/p&gt;
  &lt;/div&gt;
&lt;/div&gt;
</pre>

<p>The paragraph is a child of a <code>div</code> that doesn’t have a <code>class</code> of <code>one</code>, but it’s <em>also</em> descended from a <code>div</code> that has a <code>class</code> of <code>one</code>.  Both rules apply.</p>

<p>(Thanks to <a href="http://stephaniehobson.ca/" rel="acquaintance met">Stephanie Hobson</a> for first bringing this to my attention.)</p>]]></content:encoded>
			<wfw:commentRss>http://meyerweb.com/eric/thoughts/2012/03/07/negative-proximity/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
