<?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>greenideas &#187; CSS</title>
	<atom:link href="http://mwhenry.com/blog/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://mwhenry.com/blog</link>
	<description>A blog by Matt Henry</description>
	<lastBuildDate>Fri, 02 Jul 2010 23:26:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Responsive Web Design for Mobile</title>
		<link>http://mwhenry.com/blog/2010/07/responsive-web-design-for-mobile/</link>
		<comments>http://mwhenry.com/blog/2010/07/responsive-web-design-for-mobile/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 22:36:32 +0000</pubDate>
		<dc:creator>Matt Henry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[responsive]]></category>

		<guid isPermaLink="false">http://mwhenry.com/blog/?p=124</guid>
		<description><![CDATA[Responsive web design is undeniably the new hotness in CSS. If you’re not familiar with the technique, go and read Ethan Marcotte’s amazing article over on A List Apart. What Marcotte has created is a way to create one design that adapts to different resolutions using media queries. There are countless advantages to building sites [...]]]></description>
			<content:encoded><![CDATA[<p>Responsive web design is undeniably the new hotness in CSS. If you’re not familiar with the technique, go and read <a href="http://www.alistapart.com/articles/responsive-web-design/">Ethan Marcotte’s amazing article</a> over on <i>A List Apart</i>. What Marcotte has created is a way to create one design that adapts to different resolutions using <a href="http://www.w3.org/TR/css3-mediaqueries/">media queries</a>.</p>
<p>There are countless advantages to building sites in this way, but arguably the most compelling reason is the ability to share one layout across both desktop and mobile browsers. However, if you’re new to mobile development there are a couple of tricks you’ll need to use in order to make this work. It wasn’t really in the scope of Marcotte’s article to cover the mobile-specific aspects of his technique, so I figured a quick post was in order to fill in the gaps.</p>
<p>The example site we’ll be looking at is a hypothetical site for foodies called <a href="http://mwhenry.com/blog/examples/forkd/">Fork’d</a>. When you look at it in a normal sized desktop browser, It’s got a vertical navigation list and three columns of content. If you resize the window to be a fair bit narrower, you’ll see that the floats disappear, and the navigation as well as all of the content is lined up in a single column. This is the layout we want our mobile users to see. However, what they’re actually going to see is this:</p>
<p><img src="http://mwhenry.com/blog/images/forkd_iphone_tiny.jpg" alt="the site renders very small" style="border:1px solid #ccc" /></p>
<p>Fortunately, we just need a tiny sprinkling of pixie dust to make this work the way we expect it to. We’ll just add this meta tag to our page:</p>
<pre class="code">
<code class="html">
&lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
</code>
</pre>
<p>(For way more info on viewports, check out <a href="http://developer.apple.com/safari/library/documentation/appleapplications/reference/safariwebcontent/usingtheviewport/usingtheviewport.html">Apple’s documentation on the subject</a>.)</p>
<p>Once we put that in place, the Fork’d site renders like this:</p>
<p><img src="http://mwhenry.com/blog/images/forkd_iphone.jpg" alt="the site renders at the correct resolution" style="border:1px solid #ccc" /></p>
<p>Perfect! We now have one layout that works across different desktop screen resolutions as well as (high-end) mobile devices, and the only extra trick we had to employ was to add a single meta tag.</p>
]]></content:encoded>
			<wfw:commentRss>http://mwhenry.com/blog/2010/07/responsive-web-design-for-mobile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ugly font-variant bug</title>
		<link>http://mwhenry.com/blog/2010/04/ugly-font-variant-bug/</link>
		<comments>http://mwhenry.com/blog/2010/04/ugly-font-variant-bug/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 18:21:52 +0000</pubDate>
		<dc:creator>Matt Henry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[font-face]]></category>
		<category><![CDATA[typography]]></category>
		<category><![CDATA[webfonts]]></category>

		<guid isPermaLink="false">http://mwhenry.com/blog/?p=96</guid>
		<description><![CDATA[Here’s an annoying little bug that manifests when you try to set a CSS font-variant property (say, small-caps) with a font that doesn’t provide the requested variant. For instance, here is some text in League Gothic, pulled in via @font-face: League Gothic doesn’t have its own small caps variant. So what happens when you tell [...]]]></description>
			<content:encoded><![CDATA[<p>Here’s an annoying little bug that manifests when you try to set a CSS font-variant property (say, small-caps) with a font that doesn’t provide the requested variant. For instance, here is some text in League Gothic, pulled in via <code>@font-face</code>:</p>
<p><img src="http://mwhenry.com/blog/images/lg-normal.png" alt="Sample of league gothic text, rendered normally"/></p>
<p>League Gothic doesn’t have its own small caps variant. So what happens when you tell the browser to give you one anyway? Here it is with <code>font-variant: small-caps</code> applied as rendered in Firefox:</p>
<p><img src="http://mwhenry.com/blog/images/lg-sc-firefox.png" alt="Sample of league gothic small caps, rendered correctly in Firefox" /></p>
<p>So far, so good. But here’s what you get when you add small caps to League Gothic in Webkit:</p>
<p><img src="http://mwhenry.com/blog/images/lg-sc-webkit.png" alt="Sample of league gothic small caps, which falls back to the default font in Webkit" /></p>
<p>Whoops! Webkit-based browsers (I tested this in Safari, Webkit Nightly, and Chrome for OSX), when they don’t find the specified variant in the font itself, just go to the next font in the stack. In this case, it’s the browser’s default font.</p>
<p>So which behavior is correct? The CSS2 spec essentially left it up to implementors to decide whether or not they would dynamically scale the font to implement small caps. CSS3 removes the ambiguity:</p>
<blockquote><p>If a genuine small-caps font is not available, user agents should simulate a small-caps font, for example by taking a normal font and replacing the lowercase letters by scaled uppercase characters. (<a href="http://www.w3.org/TR/css3-fonts/#small-caps-the-font-variant-property"><cite>CSS fonts module level 3</cite></a>)</p></blockquote>
<p>Although a typographic purist might take issue with this behavior (Bringhurst rails against the practice of “rolling your own” variants by dynamically scaling the existing face), this is what the spec says browsers are supposed to do. And in fact, this is what Firefox does. Webkit, on the other hand, checks each font in the stack in order until it finds one that supplies the desired variant. As in the example above, if there’s nothing else in the stack, it will fall back on the browser’s default font. </p>
<p>Unfortunately, there aren’t really any workarounds for this bug. But it should serve to remind you yet again that it’s super-important to put a good deal of thought into your font stack. Always try to build a stack where all of the fonts are as similar as possible, so when something like this happens, your design doesn’t break too badly.</p>
<p>For reference, or if you’d like to see how your browser of choice handles these cases, <a href="http://mwhenry.com/blog/examples/font-variant/">here are some test cases together on a separate page.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mwhenry.com/blog/2010/04/ugly-font-variant-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Font-face Support Table</title>
		<link>http://mwhenry.com/blog/2009/12/font-face-support-table/</link>
		<comments>http://mwhenry.com/blog/2009/12/font-face-support-table/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 19:26:08 +0000</pubDate>
		<dc:creator>Matt Henry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[font-face]]></category>
		<category><![CDATA[typography]]></category>
		<category><![CDATA[web standards]]></category>
		<category><![CDATA[webfonts]]></category>

		<guid isPermaLink="false">http://mwhenry.com/blog/?p=84</guid>
		<description><![CDATA[I’ve been sitting on this for a little while, so I thought I’d just go ahead and publish it. For an in-depth explanation of how I got these results, check out this post. In a nutshell, it shows that all of the main desktop browsers support some kind of @font-face format, so as long as [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been sitting on this for a little while, so I thought I’d just go ahead and publish it. For an in-depth explanation of how I got these results, check out <a href="http://mwhenry.com/blog/2009/11/webfonts-and-mobile-devices/">this post.</a> In a nutshell, it shows that all of the main desktop browsers support some kind of @font-face format, so as long as you use something like the Bulletproof font-face syntax, your fonts will render in all of the the major browsers (e.g. those with &gt; 3% market share). On mobile, it’s still a Mobile Safari-only party.</p>
<table id="fontFaceSupport" class="results" cellspacing="0" width="100%">
<caption>Webfont format support by browser</caption>
<thead>
<tr class="font-types">
<th></th>
<th>Embedded Open Type (.eot)</th>
<th>TrueType (.ttf)</th>
<th>OpenType (otf)</th>
<th>Web Open Font Format (.woff)</th>
<th>SVG (.svg)</th>
</tr>
<tr>
<th colspan="6">Mobile Browsers<a href="#fontFaceSupport-note1"><sup>1</sup></a></th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="6"><a href="#fontFaceSupport"><sup id="fontFaceSupport-note1">1</sup></a> I haven’t had a chance to test Mozilla’s portable offerings</td>
</tr>
</tfoot>
<tbody>
<tr>
<th>Mobile IE (≤ WinMo 6.5)</th>
<td class="no">No</td>
<td class="no">No</td>
<td class="no">No</td>
<td class="no">No</td>
<td class="no">No</td>
</tr>
<tr>
<th>Opera Mini (≤ v4.2)</th>
<td class="no">No</td>
<td class="no">No</td>
<td class="no">No</td>
<td class="no">No</td>
<td class="no">No</td>
</tr>
<tr>
<th>Opera Mobile (9.7 Beta WinMo)</th>
<td class="no">No</td>
<td class="no">No</td>
<td class="no">No</td>
<td class="no">No</td>
<td class="no">No</td>
</tr>
<tr>
<th>Palm WebOS </th>
<td class="no">No</td>
<td class="no">No</td>
<td class="no">No</td>
<td class="no">No</td>
<td class="no">No</td>
</tr>
<tr>
<th>Mobile Safari (3.1)</th>
<td class="no">No</td>
<td class="no">No</td>
<td class="no">No</td>
<td class="no">No</td>
<td class="yes">Yes!</td>
</tr>
<tr>
<th>Android (≥ 2.2 SDK)</th>
<td class="no">No</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="no">No</td>
<td class="no">No</td>
</tr>
</tbody>
<thead>
<tr>
<th colspan="6">Desktop Browsers (Incomplete. I’ll be filling this in more over time)</th>
</tr>
</thead>
<tbody>
<tr>
<th>IE (≥ 5.5)</th>
<td class="yes">Yes</td>
<td class="no">No</td>
<td class="no">No</td>
<td class="no">No</td>
<td class="no">No</td>
</tr>
<tr>
<th>Firefox</th>
<td class="no">No</td>
<td class="yes">Yes (≥ 3.5)</td>
<td class="yes">Yes (≥ 3.5)</td>
<td class="yes">Yes (≥ 3.6)</td>
<td class="no">No</td>
</tr>
<tr>
<th>Safari</th>
<td class="no">No</td>
<td class="yes">Yes (≥ 3.1)</td>
<td class="yes">Yes (≥ 3.1)</td>
<td class="no">No</td>
<td class="yes">Yes (≥ 3.1)</td>
</tr>
<tr>
<th>Opera</th>
<td class="no">No</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="no">No</td>
<td class="yes">Yes</td>
</tr>
<tr>
<th>Chrome</th>
<td class="no">No</td>
<td class="no">No</td>
<td class="no">No</td>
<td class="no">No</td>
<td class="yes">Yes (≥ 3.0)</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://mwhenry.com/blog/2009/12/font-face-support-table/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Shiny CSS-only iPhone Buttons</title>
		<link>http://mwhenry.com/blog/2009/11/shiny-css-only-iphone-buttons/</link>
		<comments>http://mwhenry.com/blog/2009/11/shiny-css-only-iphone-buttons/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 19:24:50 +0000</pubDate>
		<dc:creator>Matt Henry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://mwhenry.com/blog/?p=80</guid>
		<description><![CDATA[Just a quickie: I came up with these CSS-only iPhone-style buttons as part of a bigger pet project I’m working on. They make heavy use of -webkit-gradient instead of the typical PNG-based solution you typically see out there, such as in iUI. The CSS is here, and be sure to check out the example buttons. [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quickie: I came up with these CSS-only iPhone-style buttons as part of a bigger pet project I’m working on. They make heavy use of <code>-webkit-gradient</code> instead of the typical PNG-based solution you typically see out there, such as in iUI.</p>
<p>The CSS is <a href="/blog/examples/iphone_buttons/styles/ui.css">here</a>, and be sure to check out the <a href="/blog/examples/iphone_buttons/">example buttons</a>.</p>
<p>The one thing I’m not crazy about when you use these styles on an actual device is that the normal <code>:active</code> state doesn’t get triggered, so I kind of had to half-ass it with a <code>:hover</code> so you’d see the “active” style as the button sheet eases out (if you’ve wired the transitions together).</p>
<p>Enjoy, and please let me know if you find them useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://mwhenry.com/blog/2009/11/shiny-css-only-iphone-buttons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Webfonts and Mobile Devices</title>
		<link>http://mwhenry.com/blog/2009/11/webfonts-and-mobile-devices/</link>
		<comments>http://mwhenry.com/blog/2009/11/webfonts-and-mobile-devices/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 23:32:55 +0000</pubDate>
		<dc:creator>Matt Henry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[font-face]]></category>
		<category><![CDATA[typography]]></category>
		<category><![CDATA[web standards]]></category>
		<category><![CDATA[webfonts]]></category>

		<guid isPermaLink="false">http://mwhenry.com/blog/?p=58</guid>
		<description><![CDATA[If you pay even a little attention to emerging trends in Web Standards, you’re no doubt familiar with the explosion in interest in the CSS @font-face property. This property goes back to CSS2, and has been supported in IE as far back as 5.5, but @font-face support is being added at a rapid pace to [...]]]></description>
			<content:encoded><![CDATA[<div class="image"><img src="/blog/images/chunk.gif" alt="" /></div>
<p>If you pay even a little attention to emerging trends in Web Standards, you’re no doubt familiar with the explosion in interest in the CSS <code>@font-face</code> property. This property goes back to CSS2, and has been supported in IE as far back as 5.5, but <code>@font-face</code> support is being added at a rapid pace to other browsers, hence the recent surge of interest.</p>
<p>As someone who spends his days developing for mobile platforms, I wanted to check on how <code>@font-face</code> support was progressing in mobile browsers. Read on to see what I found out.</p>
<h3>Methodology</h3>
<p>I put together a <a href="/blog/examples/font-face-test/">test page</a> I used to check the extent of <code>@font-face</code> support.</p>
<p>I made test elements and separate font families for each font format being tested (e.g. there’s a font family called “ChunkFive SVG” that will only be applied to the <code>span#SVG</code> test element. View source on the sample page for more details). I checked for <code>@font-face</code> support with three criteria (two automated):</p>
<ol>
<li>Ask each test element what font-family it thinks it is being rendered with. This is done via the <code>window.getComputedStyle()</code> method (and why I’m sticking with testing W3C compliant browsers at the moment). If all goes well, the return value should be some variant of ChunkFive.</li>
<li>Check to see if the rendered text is wider than text rendered in the browser’s default font. For the test to pass, it has to be wider, since there are font size bugs in Mobile Safari (see below).</li>
<li>Eyeball it. In some cases, the criteria above aren’t met, so the <code>@font-face</code> implementation is incorrect, but it’s close enough to be saved with some extra TLC.</li>
</ol>
<p>I also included a test case based on <a href="http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/">Paul Irish’s Bulletproof @font-face syntax</a> as a bit of a sanity check and for the sake of having a less contrived example. Lastly, I threw in samples of Cufon and sIFR text, just for comparison.</p>
<p>All that said, here’s what I came up with.</p>
<h3>Results</h3>
<h4>Mobile Safari 3.0</h4>
<p>Support for <code>@font-face</code> in Mobile Safari is currently broken in several frustrating ways:</p>
<ol>
<li>Certain formats (e.g. TTF &amp; OTF), when applied, falsely report that they have been successfully applied. That is, if you check the value of font-family from getComputedStyle() on that element, it will return the <code>@font-face value</code>, even though it doesn’t render as such. (<strong>Update 11/13:</strong> As Paul Irish correctly pointed out in the comments to this post, Opera is actually the only browser that returns the font that’s actually used when <code>getComputedStyle()</code> is called.)</li>
<li>What’s worse, is that when this situation occurs, if no fallback <code>font-family</code> is specified, the text will render with the browser’s default <code>font-family</code> (as you’d expect), but <em>it does so at less than the default font size</em>. Fortunately, if you specify a fallback value in the <code>font-family</code> declaration, it will render the fallback typeface at the correct size, so always remember to pick a degradation path for your fonts.</li>
<li>Another issue with text size arises if you use the SVG format to get around the lack of support for other formats on the iPhone. While you can indeed use SVG fonts in your font-face rules on the iPhone, text rendered in SVG fonts will render at smaller than expected sizes. So if you opt for this strategy, just plan for this consequence, and correct the font sizes accordingly.  Desktop browsers that support SVG fonts (Safari &amp; Chrome) don’t exhibit this bug, so you need to target this font-size fix to mobile browsers. You can easily handle this case with a <code>@media</code> query in your stylesheet. Users of the Bulletproof Syntax will see this bug, since it will fall through to SVG on Mobile Safari.
<div class="image alignRight"><img src="/blog/images/SVGfail.png" alt="Mobile Safari renders SVG text too small" /><span class="caption">SVG fonts on Mobile Safari render too small out of the box.</span></div>
</li>
<li>Another (possibly more academic) issue is that calling <code>getComputedStyle()</code> on text rendered with an SVG font will not return the font-family value in your <code>@font-face</code> declaration, even though it renders with that font family. This could prove troublesome if you’re using Javascript to test the success of your font rendering.</li>
</ol>
<p>So if you need to use <code>@font-face</code> on Mobile Safari today, you should be sure to include an SVG version in your <code>@font-face</code> declaration, and you should patch any text size bugs with a <code>@media</code> query. (If you’re not familiar with @media queries, you should <a href="http://www.w3.org/TR/css3-mediaqueries/">read up on them</a>.)</p>
<p>Incidentally, Opera 10 on the desktop also shows a slight variation in font-size when using SVG fonts as well. However, since it supports TrueType and OpenType formats, this shouldn’t cause any particular issues if you’re using the bulletproof syntax (that’s why it’s bulletproof, yo).</p>
<h4>Android 2.0 SDK</h4>
<p>Short and not so sweet: There is no support in the Android 2.0 SDK for any webfont format. If you’re targeting Android, use Cufon.</p>
<h4>Palm WebOS</h4>
<p>Like Android, there is currently no support whatsoever for @font-face in WebOS. Additionally, in my (not at all extensive) tests, Cufon didn’t even appear to work at all (as in no text was rendered).</p>
<h3>Summary</h3>
<p>In short, if you want your mobile site to join the Nice Web Type bandwagon, you have a little more work to do than for your desktop site. Of all of the modern WebKit-based mobile browsers, only Mobile Safari provides any kind of @font-face support. And even that support is buggy and incomplete. However, if you are aware of these limitations ahead of time (which you ought to be by this point in the post), you have a couple of tricks in your back pocket to keep things running smoothly.</p>
<h3>What’s Next?</h3>
<p>In the next little while, I’ll extend these tests to cover IE on WinMo and also do a similar write-up for <code>@font-face</code> support in desktop browsers and tabulate all of the results in a little more formal manner.</p>
<p><strong>Update:</strong> In case anyone wants to take a look under the hood of these tests without jumping through hoops in Firebug or View Source, the test code is <a href="http://github.com/greenideas/font-face-test">up on Github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mwhenry.com/blog/2009/11/webfonts-and-mobile-devices/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>The Rounded Corners of Tomorrow… Today!</title>
		<link>http://mwhenry.com/blog/2008/10/the-rounded-corners-of-tomorrow-today/</link>
		<comments>http://mwhenry.com/blog/2008/10/the-rounded-corners-of-tomorrow-today/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 04:46:12 +0000</pubDate>
		<dc:creator>Matt Henry</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[front-end]]></category>
		<category><![CDATA[standards]]></category>
		<category><![CDATA[svg]]></category>

		<guid isPermaLink="false">http://mwhenry.com/?p=19</guid>
		<description><![CDATA[Hey, you know what can be a real pain in the tail? CSS rounded corners. Of course there are battle-tested, workhorse solutions out there, like sliding doors, or a handful of Javascript-based alternatives. But rounded corners are such a common element of web design and seem like a natural extension of the designer’s existing toolkit [...]]]></description>
			<content:encoded><![CDATA[<p>Hey, you know what can be a real pain in the tail? CSS rounded corners. Of course there are battle-tested, workhorse solutions out there, like <a href="http://www.alistapart.com/articles/slidingdoors/">sliding doors</a>, or a handful of <a href="http://www.curvycorners.net/">Javascript-based</a> alternatives. But rounded corners are such a common element of web design and seem like a natural extension of the designer’s existing toolkit that it only makes sense that there should be a way to implement them with pure CSS. The good news is that <code>border-radius</code> is indeed <a href="http://www.w3.org/TR/css3-background/#border-radius">coming in CSS3</a>. The better news is that you can start using it today, as long as you’re only targeting Gecko &amp; Webkit. Before we get to that though, let’s look at the way it’s supposed to work according to the spec.</p>
<p>As you might expect, the <code>border-radius</code> property is used a lot like <code>border</code>. That is, you can specify one value for each corner (<code>border-radius: 10px;</code>), one value per corner (<code>border-radius: 1px 2px 3px 4px;</code>), or values for opposite corners (<code>border-radius: 5px 10px</code>). It actually gets more complicated, since in addition to describing corners with one radius (i.e. those with semi-circular curves), you can make elliptically rounded corners by naming two radii. For more detail on this, take a look at the draft spec. Lastly, you can use a property for each corner, <code>border-top-left-radius: 2em;</code>, etc. So, assuming there aren’t any major changes in the spec, expect this to be what gets implemented as part of CSS3, and what you’ll ultimately using in your code.</p>
<p>But what about now? Here? Today? It happens that two of the standards-aware, forward-thinking rendering engines have developed proprietary extensions to CSS that should stand in for <code>border-radius</code> until certain <a href="http://www.css3.info/border-radius-apple-vs-mozilla/">ambiguities</a> in the spec can be resolved, and the property is implented according to the standard. So if you want to use <code>border-radius</code> in your code today, you’ll have to use both the Mozilla– and Webkit-specific CSS properties. Fortunately, both of the proprietary extensions work in the current major releases of their respective browsers.</p>
<p>If you’re making a box with four corners of the same radius, the syntax is the same in Mozilla and Webkit:</p>
<pre class="code">-moz-border-radius: 10px; /* 4 corners of radius = 4px*/
-webkit-border-radius: 10px; /* Same as Mozilla */</pre>
<p>To specify different radii for each corner, things diverge somewhat.</p>
<pre class="code">/* Mozilla: */
-moz-border-radius: 1px 2px 3px 4px;
/* Webkit:
    (The four declarations below amount to the
    same thing as the single rule above) */
-webkit-border-top-left-radius: 1px;
-webkit-border-top-right-radius: 2px;
-webkit-border-bottom-right-radius: 3px;
-webkit-border-bottom-left-radius: 4px;</pre>
<p>And that’s the guts of it. So to make a tabbed navigation list, you would use a declaration along the lines of the following (and <a href="examples/borderradius.html">see the below code in action.</a>):</p>
<pre class="code">li {
  border: 1px solid #587402;
  border-bottom: none;
  border-radius: 0 10px 0 10px;
  -moz-border-radius: 10px 10px 0 0;
  -webkit-border-top-left-radius: 10px;
  -webkit-border-top-right-radius: 10px;
  list-style-type: none;
  float: left;
  padding: .5em 1em 0 1em;
}</pre>
<p>There you have it. But there are just a couple of other things I want to point out. If the container you’re rounding the corners of has only text content and a background in it, the background will clip to the rounded corners. And indeed, according to the spec, <em>any</em> the contents of a block-level element on which a border-radius is set should clip do the same as long as you set <code>overflow: hidden</code> on those contents. However, the implementations just aren’t there yet. Instead, with anything over and above plain HTML text (for instance, an <code>img</code> or <code>iframe</code>) inside such a container, the square corners will peek outside of the rounded container. (<a href="examples/borderradius.html#pointy">Example</a>)</p>
<p>One solution would be to make the border thick enough that the corners of the inner element can’t poke through the outer border (<a href="examples/borderradius.html#bigBorder">like so</a>). Though inelegant, this will work just fine if you don’t need everything to round nicely. And this method should suffice for whatever kind of content you’re trying to stuff into your nicely rounded box.</p>
<p>However, if it’s an image you’re putting in the box and you need the inner corners to be rounded as well as the outer corners, then the only answer (for now) is to <a href="examples/borderradius.html#bigBorder">set the image as a background</a>. Still, if the language of the spec is any indication, it won’t always be this way.</p>
<p>For the poor soul who is trying to squeeze iframe content into a rounded corner box, you’re essentially out of luck at the moment. You can certainly use the thick border method I described above, but short of that, you’ll have to look to the bleeding edge. That is to say, you’ll need something which isn’t yet in any production-quality browser, but that is currently in the Webkit nightlies. I speak of the arcane methods of <code>-webkit-mask-image</code>. This property can take a png or an svg as its url, and pretty much anything you apply it to will play nice and clip to the shape of the image. <a href="examples/borderradius.html#map">See for yourself.</a> Still, this last bit is obviously not anything anybody will be using in production code for some time to come.</p>
<p>After reading all of this, if nothing else, I do hope that you’ve come away with a better idea of some of the great things that the CSS working group has in store for you, the developer. But even moreso, hopefully there’s something in all of this mess that you’ll be able to put to use today.</p>
]]></content:encoded>
			<wfw:commentRss>http://mwhenry.com/blog/2008/10/the-rounded-corners-of-tomorrow-today/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What I’m Reading: 3/24</title>
		<link>http://mwhenry.com/blog/2008/03/what-im-reading-324/</link>
		<comments>http://mwhenry.com/blog/2008/03/what-im-reading-324/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 17:22:42 +0000</pubDate>
		<dc:creator>Matt Henry</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[games]]></category>

		<guid isPermaLink="false">http://mwhenry.com/?p=12</guid>
		<description><![CDATA[Nine Techniques for CSS Image Replacement: If you spend any time at all playing with CSS, you know that there are a full bajillion techniques for replacing text with an image. It’s a lot to remember, and I’ll fess up that I tend to use whatever one I happened to have read about most recently [...]]]></description>
			<content:encoded><![CDATA[<ol>
<li><a href="http://css-tricks.com/nine-techniques-for-css-image-replacement/">Nine Techniques for CSS Image Replacement</a>: If you spend any time at all playing with CSS, you know that there are a full bajillion techniques for replacing text with an image. It’s a lot to remember, and I’ll fess up that I tend to use whatever one I happened to have read about most recently rather than taking a considered approach to which of them might be the best solution for a given situation. No more! The above-linked post does a great job of running through the pros and cons of the 9 (9!) major techniques, and from now on you (meaning “I”) no longer have any excuse to not use the best, semantic, most accessible one at every opportunity.</li>
<li><a href="http://meyerweb.com/eric/thoughts/2008/03/23/drugs-bugs-and-ie8/">Drugs, Bugs, and IE8</a>: A predictably good read from Eric Meyer, but I link to it mainly to have an excuse to echo the following point: There are a lot of beta browsers out there right now (one less, now that Safari 3 has shipped). If you’re testing your sites in them and something renders in any way other than what you were expecting, submit a bug report. <strong>Don’t</strong> change your code.</li>
<li><a href="http://webkit.org/blog/166/optimizing-page-loading-in-web-browser/">Optimizing Page Loading in the Web Browser</a>: For the browser builders, network latency is at least as big a problem as connection speed.</li>
<li><a href="http://www.gamasutra.com/view/feature/3581/a_japanese_rpg_primer_the_.php">A Japanese RPG Primer: The Essential 20</a>: Last week, <a href="http://www.gamasutra.com/" title="Gamasutra">Gamasutra</a> published this list of the best of the best in Japanese RPGs throughout the ages. It’s a top-20, so it’s not exhaustive, but it’s sure as hell exhaust<em>ing</em>–i’ve been chipping away at this beastie since last week. Anyway, if you’re at all into JRPGs, it’s a really fun read. It’s also neat to see some old favorites put into context alongside some seminal games that you may never have been exposed to.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://mwhenry.com/blog/2008/03/what-im-reading-324/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
