<?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>David B. Calhoun - Developer Blog &#187; css</title>
	<atom:link href="http://davidbcalhoun.com/tag/css/feed" rel="self" type="application/rss+xml" />
	<link>http://davidbcalhoun.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 08 Sep 2010 18:28:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Thursday links (July 8)</title>
		<link>http://davidbcalhoun.com/2010/thursday-links-july-8</link>
		<comments>http://davidbcalhoun.com/2010/thursday-links-july-8#comments</comments>
		<pubDate>Fri, 09 Jul 2010 04:00:09 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[links]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://davidbcalhoun.com/?p=338</guid>
		<description><![CDATA[Mobile YouTube Mobile Gets a Kick Start Battle of Champions: HTC Droid Incredible vs. Palm Pre Plus Designing for the Retina Display (326ppi) AUDIO: John Resig: You Don’t Know Mobile (Webstyle Magazine) &#8211; ~$5,000 minimum to do mobile testing Tapworthy: Designing Great iPhone Apps eMobile: We have the fastest network in Japan! Apple iPad User [...]]]></description>
			<content:encoded><![CDATA[<h3>Mobile</h3>
<p><a href="http://googlemobile.blogspot.com/2010/07/youtube-mobile-gets-kick-start.html">YouTube Mobile Gets a Kick Start</a><br />
<a href="http://blog.laptopmag.com/htc-droid-incredible-vs-palm-pre-plus">Battle of Champions: HTC Droid Incredible vs. Palm Pre Plus</a><br />
<a href="http://www.lukew.com/ff/entry.asp?1142">Designing for the Retina Display (326ppi)</a><br />
<a href="http://webstylemag.com/you-dont-know-mobile" class="audio">AUDIO: John Resig: You Don’t Know Mobile (Webstyle Magazine)</a> &#8211; ~$5,000 minimum to do mobile testing<br />
<a href="http://www.amazon.com/Tapworthy-Designing-Great-iPhone-Apps/dp/1449381650">Tapworthy: Designing Great iPhone Apps</a><br />
<a href="http://www.intomobile.com/2010/07/08/emobile-we-have-the-fastest-network-in-japan/">eMobile: We have the fastest network in Japan!</a><br />
<a href="http://ymobileblog.com/blog/2010/07/08/apple-ipad-user-analysis-%E2%80%94-phase-ii/">Apple iPad User Analysis — Phase II</a><br />
<a href="http://www.youtube.com/watch?v=6_TFHqIHBqM" class="video">VIDEO: Using iPhone with a Braille display (Victor Tsaran)</a><br />
<a href="http://www.pewinternet.org/Reports/2010/Mobile-Access-2010.aspx">Mobile Access 2010 (Pew Research)</a><br />
<a href="http://www.prnewswire.com/news-releases/comscore-reports-may-2010-us-mobile-subscriber-market-share-98031904.html">BlackBerry and iPhone losing ground to Android, overall smartphone growth (comScore data)</a></p>
<h3>JavaScript</h3>
<p><a href="http://blog.mozilla.com/dherman/2010/07/08/javascript-needs-modules/">JavaScript needs modules!</a><br />
<a href="http://www.dustindiaz.com/javascript-cache-provider/">JavaScript Cache Provider (Dustin Diaz)</a><br />
<a href="http://www.adequatelygood.com/2010/7/Writing-Testable-JavaScript">Writing Testable JavaScript</a></p>
<h3>CSS</h3>
<p><a href="http://5by5.tv/bigwebshow/11" class="video">VIDEO: Nicole Sullivan on CSS (The Big Web Show)</a><br />
<a href="http://css-tricks.com/css-media-queries/">CSS Media Queries &#038; Using Available Space</a><br />
<a href="http://www.nczonline.net/blog/2010/07/06/data-uris-make-css-sprites-obsolete/">Data URIs make CSS sprites obsolete (Nicholas Zakas)</a></p>
<h3>Books</h3>
<p><a href="http://books.alistapart.com/product/html5-for-web-designers">HTML5 For Web Designers</a><br />
<a href="http://www.amazon.com/Tapworthy-Designing-Great-iPhone-Apps/dp/1449381650">Tapworthy: Designing Great iPhone Apps</a><br />
<a href="http://www.amazon.com/HTML5-Up-Running-Mark-Pilgrim/dp/0596806027">HTML5: Up and Running</a><br />
<a href="http://www.amazon.com/JavaScript-Patterns-Stoyan-Stefanov/dp/0596806752">JavaScript Patterns</a></p>
<h3>Etc.</h3>
<p><a href="http://web.enavu.com/snippets/web-forms-semantic-mark-up-in-our-forms-part-2/">Web Forms: Semantic Mark Up in our Forms [part 2]</a><br />
<a href="http://trentwalton.com/2010/07/05/non-hover/">Non Hover</a> &#8211; “Elements that rely only on mousemove, mouseover, mouseout or the CSS pseudo-class :hover may not always behave as expected on a touch-screen device such as iPad or iPhone.”<br />
<a href="http://www.xanthir.com/video/">Video to ASCII conversion with Canvas</a><br />
<a href="http://accessibiliteweb.com/stuff/captcha-slider.html">CAPTCHA slider</a><br />
<a href="http://www.google.com/support/webmasters/bin/topic.py?topic=21997">Rich snippets and structured markup (Google Webmaster Central) (SEO)</a><br />
<a href="http://hacks.mozilla.org/2010/07/firefox-4-beta-1-is-here-whats-in-it-for-web-developers/">Firefox 4 beta 1 is here – what’s in it for web developers?</a></p>
]]></content:encoded>
			<wfw:commentRss>http://davidbcalhoun.com/2010/thursday-links-july-8/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using mobile-specific HTML, CSS, and JavaScript (Mobile web part 5)</title>
		<link>http://davidbcalhoun.com/2010/using-mobile-specific-html-css-javascript</link>
		<comments>http://davidbcalhoun.com/2010/using-mobile-specific-html-css-javascript#comments</comments>
		<pubDate>Wed, 30 Jun 2010 03:27:11 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[mobile]]></category>
		<category><![CDATA[basejs]]></category>
		<category><![CDATA[blackberry.network]]></category>
		<category><![CDATA[blackberry.system]]></category>
		<category><![CDATA[capture api]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[gesture events]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[iui]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jqtouch]]></category>
		<category><![CDATA[media queries]]></category>
		<category><![CDATA[mozorientation]]></category>
		<category><![CDATA[orientationchange]]></category>
		<category><![CDATA[pastrykit]]></category>
		<category><![CDATA[touch events]]></category>
		<category><![CDATA[webkit]]></category>
		<category><![CDATA[xui]]></category>

		<guid isPermaLink="false">http://davidbcalhoun.com/?p=317</guid>
		<description><![CDATA[Mobile-specific HTML Use the viewport tag to properly fit the content to the screen: &#60;meta name=&#34;viewport&#34; content=&#34;width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no&#34;/&#62; Use the tel scheme for telephone numbers, allowing users to initiate calls by clicking: &#60;a href=&#34;tel:18005555555&#34;&#62;Call us at 1-800-555-5555&#60;/a&#62; Or use the sms scheme to initiate an SMS message: &#60;a href=&#34;sms:18005555555&#34;&#62; &#60;a href=&#34;sms:18005555555,18005555556&#34;&#62; &#60;!-- multiple [...]]]></description>
			<content:encoded><![CDATA[<h3>Mobile-specific HTML</h3>
<p>Use the <a href="http://davidbcalhoun.com/2010/viewport-metatag">viewport tag</a> to properly fit the content to the screen:</p>
<pre name="code" class="html">
&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot;/&gt;
</pre>
<p>Use the <a href="http://www.rfc-editor.org/rfc/rfc3966.txt">tel scheme</a> for telephone numbers, allowing users to initiate calls by clicking:</p>
<pre name="code" class="html">
&lt;a href=&quot;tel:18005555555&quot;&gt;Call us at 1-800-555-5555&lt;/a&gt;
</pre>
<p>Or use the <a href="http://www.rfc-editor.org/rfc/rfc5724.txt">sms scheme</a> to initiate an SMS message:</p>
<pre name="code" class="html">
&lt;a href=&quot;sms:18005555555&quot;&gt;
&lt;a href=&quot;sms:18005555555,18005555556&quot;&gt;          &lt;!-- multiple recipients --&gt;
&lt;a href=&quot;sms:18005555555?body=Text+goes+here&quot;&gt;  &lt;!-- predefined message body --&gt;
</pre>
<p>You also have access to several <a href="http://developer.apple.com/safari/library/documentation/appleapplications/reference/safariwebcontent/configuringwebapplications/configuringwebapplications.html">Apple-specific tags to use in your web application (iPhone and iPod Touch)</a>:</p>
<pre name="code" class="html">
// iOS 1.1.3+: this is the icon that's used when the user adds your app to the home screen
&lt;link rel=&quot;apple-touch-icon&quot; href=&quot;/custom_icon.png&quot;/&gt;

// iOS 3+: full-screen startup splash screen image
&lt;link rel=&quot;apple-touch-startup-image&quot; href=&quot;/startup.png&quot;&gt;

// enable full-screen mode
&lt;meta name=&quot;apple-mobile-web-app-capable&quot; content=&quot;yes&quot; /&gt;

// controls the appearance of the status bar in full-screen mode
&lt;meta name=&quot;apple-mobile-web-app-status-bar-style&quot; content=&quot;black&quot; /&gt;
</pre>
<p>And also some handy attributes to turn off annoying autocorrect features (works on iPhone, but anything else?):</p>
<pre name="code" class="html">
&lt;input autocorrect=&quot;off&quot; autocomplete=&quot;off&quot; autocapitalize=&quot;off&quot;&gt;
</pre>
<h3>Mobile-specific CSS</h3>
<p><a href="http://www.w3.org/TR/css3-mediaqueries/">Media queries</a> enable you to target specific features (screen width, orientation, resolution) within CSS itself.  You can use them two ways: 1) inline in a CSS stylesheet or 2) as the &#8220;media&#8221; attribute in the link tag, which targets an external stylesheet.  The following is an example of inline CSS that&#8217;s applied only when the device is in portrait mode:</p>
<pre name="code" class="css">
@media all and (orientation: portrait) {
	body { }
	div { }
}
</pre>
<p>Here&#8217;s the same media query using the other method, which points to an external stylesheet (not recommended, as it creates another network request):</p>
<pre name="code" class="html">
&lt;link rel=&quot;stylesheet&quot; media=&quot;all and (orientation: portrait)&quot; href=&quot;portrait.css&quot; /&gt;
</pre>
<p>Here&#8217;s a few examples:</p>
<pre name="code" class="css">
// target mobile devices
@media only screen and (max-device-width: 480px) {
	body { max-width: 100%; }
}

// recent Webkit-specific media query to target the iPhone 4's high-resolution Retina display
@media only screen and (-webkit-min-device-pixel-ratio: 2) {
	// CSS goes here
}

// should technically achieve a similar result to the above query,
// targeting based on screen resolution (the iPhone 4 has 326 ppi/dpi)
@media only screen and (min-resolution: 300dpi) {
	// CSS goes here
}
</pre>
<p>Read more: <a href="https://developer.mozilla.org/en/css/media_queries">Media queries (Mozilla Developer Center)</a></p>
<p>(edit: removed section on <code>body[orient='portrait']</code>, which requires JavaScript and is in error.  See <a href="http://davidbcalhoun.com/2010/dealing-with-device-orientation">Part 6: Dealing with device orientation</a> for more details.)</p>
<h3>Mobile-specific JavaScript</h3>
<p>window.devicePixelRatio: determine screen resolution (analogue to the media query).  (iPhone 4 has the value 2, while Nexus One has the value 1.5).</p>
<p><a href="https://developer.mozilla.org/en/DOM/window.navigator.onLine">window.navigator.onLine</a> (boolean): not strictly mobile, but helpful for apps to determine if they&#8217;re being run offline</p>
<p><a href="http://developer.apple.com/safari/library/documentation/appleapplications/reference/safarihtmlref/articles/metatags.html">window.navigator.standalone</a> (boolean, iOS 2.1+): determine if it&#8217;s running in full-screen mode (Apple only?)</p>
<p><a href="http://developer.apple.com/safari/library/documentation/appleapplications/reference/safariwebcontent/handlingevents/handlingevents.html">touch events (iOS, Android 2.2+)</a>: touchstart, touchmove, touchend, touchcancel</p>
<p><a href="http://developer.apple.com/safari/library/documentation/internetweb/conceptual/safarivisualeffectsprogguide/InteractiveVisualEffects/InteractiveVisualEffects.html">gesture events (Apple only, iOS 2+)</a>: gesturestart, gesturechange, gesturend give access to predefined gestures (rotation, scale, position)</p>
<p><a href="http://ajaxian.com/archives/iphone-windowonorientationchange-code">window.orientation and orientationchange event</a>: triggered every 90 degrees of rotation (portrait and landscape modes)</p>
<p><a href="https://developer.mozilla.org/en/Detecting_device_orientation">MozOrientation</a> (Fennec/Firefox Mobile, Firefox 3.5+): also not strictly mobile.  Gives access to the device&#8217;s accelerometer (x-y-z orientation data), updated periodically.  Works on Android phones (I tested on the Nexus One), Windows Mobile, etc.  On the desktop this works with laptops such as Thinkpads and MacBooks.</p>
<p>-near future: camera/microphone access in Android 2.3 (announced at Google I/O 2010) through the <a href="http://www.w3.org/TR/capture-api/">Capture API</a></p>
<p>If you&#8217;re developing for a BlackBerry Widget, you have access to proprietary information through the <a href="http://www.blackberry.com/developers/docs/widgetapi/Summary_system.html">blackberry object</a> (which gives access to useful information such as blackberry.network [returns values such as CDMA and Wi-Fi] and blackberry.system).</p>
<p>You also have the option to use <a href="http://phonegap.com/">PhoneGap</a>, which augments JavaScript and gives you access to more phone features that native apps would have access to.</p>
<h3>Use a mobile-optimized JavaScript library</h3>
<p>Because smartphone browsers are standards-based, the aim of a JavaScript library on mobile is less towards API normalization and more towards providing an actual UI framework, usually to emulate the feel of native apps (and to provide easier workarounds to <a href="http://doctyper.com/archives/200808/fixed-positioning-on-mobile-safari/">lack of access to position:fixed</a>).  We&#8217;ve seen a few libraries released that emulate the iPhone UI, and in the future we might see libraries emulating the Android UI, as well as entirely new UIs.</p>
<p>There&#8217;s also a bit to be said about simply loading full desktop JavaScript libraries into mobile clients.  In my opinion this doesn&#8217;t particularly make sense, especially in a world where latency and bandwidth are so much more of a concern.  It doesn&#8217;t make sense to force the user wait longer and download code that&#8217;s ultimately useless to them (hacks for desktop browsers such as IE 6, etc).</p>
<p>Here&#8217;s a few of the mobile libraries now available:<br />
-<a href="http://www.sencha.com/">Sencha Touch</a><br />
-<a href="http://paularmstrongdesigns.com/projects/basejs/">baseJS</a><br />
-<a href="http://xuijs.com/">XUI</a><br />
-<a href="http://www.jqtouch.com/">jQTouch</a>: jQuery-style mobile library that emulates the look of the iPhone UI<br />
-<a href="http://code.google.com/p/iui/">iUI</a>: the first JavaScript library to be released, emulates the look of the iPhone UI.  Originally coded by <a href="http://www.joehewitt.com/">Joe Hewitt</a>.<br />
-<a href="http://davidbcalhoun.com/2009/pastrykit-digging-into-an-apple-pie">PastryKit</a>: Apple proprietary non-public JavaScript library with no available documentation</p>
<h3>Take advantage of new stuff!</h3>
<p>While not specific to mobile, there&#8217;s a lot of new stuff in general that you can use.  If you limit yourself to the top smartphones (iPhone, Android, and maybe webOS), compared to the desktop you immediately have access to an even wider array of new stuff, especially many Webkit proprietary features, since most of these top smartphones have browsers based on Webkit.</p>
<p>-HTML: new tags (<a href="http://diveintohtml5.org/">HTML5</a> (I&#8217;m sure you&#8217;ve heard of it by now…))<br />
-CSS: <a href="http://webkit.org/blog/130/css-transforms/">2d transforms</a>, <a href="http://webkit.org/blog/386/3d-transforms/">3d transforms</a>, animation, <a href="http://border-radius.com/">border radius</a>, <a href="https://developer.mozilla.org/en/css/@font-face">custom fonts with @font-face</a>, etc.<br />
-JavaScript: <a href="http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/">strict mode</a>, <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Core_Language_Features#Constants">constants</a>, <a href="http://davidbcalhoun.com/2009/javascript-tidbit-block-scope-with-let">block scope</a>, <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Date">Date.now()</a>, etc.</p>
<h3>Related posts</h3>
<p>This post is part of a series on the mobile web.  You can read the other parts of the series here:<br />
<a href="http://davidbcalhoun.com/2010/viewport-metatag">Part 1: The viewport metatag</a><br />
<a href="http://davidbcalhoun.com/2010/the-mobile-developers-toolkit-mobile-web-part-2">Part 2: The mobile developer’s toolkit</a><br />
<a href="http://davidbcalhoun.com/2010/designing-buttons-that-dont-suck">Part 3: Designing buttons that don’t suck</a><br />
<a href="http://davidbcalhoun.com/2010/on-designing-a-mobile-webpage">Part 4: On designing a mobile webpage</a></p>
]]></content:encoded>
			<wfw:commentRss>http://davidbcalhoun.com/2010/using-mobile-specific-html-css-javascript/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>A Clockwork Box</title>
		<link>http://davidbcalhoun.com/2010/a-clockwork-box</link>
		<comments>http://davidbcalhoun.com/2010/a-clockwork-box#comments</comments>
		<pubDate>Tue, 02 Mar 2010 23:22:59 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[box model]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://davidbcalhoun.com/?p=171</guid>
		<description><![CDATA[With CSS there are always various ways to accomplish something. After reading this short tidbit, you should be familiar with the various ways of controlling the size of an element&#8217;s padding, border, and margin, and you should know what the handy &#8220;clockwork&#8221; tip is, and how it will be useful to remember when you&#8217;re putting [...]]]></description>
			<content:encoded><![CDATA[<div class="intro"><img src="http://davidbcalhoun.com/wp-content/uploads/2010/03/clockwork-box.png" alt="Clockwork Orange cover" title="Clockwork Orange cover" width="450" height="320" class="left alignleft size-full wp-image-174" />
<div>With CSS there are always various ways to accomplish something.  After reading this short tidbit, you should be familiar with the various ways of controlling the size of an element&#8217;s padding, border, and margin, and you should know what the handy &#8220;clockwork&#8221; tip is, and how it will be useful to remember when you&#8217;re putting your CSS into practice.</div>
</div>
<h3>Equal values on all four sides</h3>
<p>If all four values (top, right, bottom, and left) are equal, then you simply write the following:</p>
<pre name="code" class="css">
padding: 1px;
border-width: 1px;
margin: 1px;
</pre>
<h3>The longhand way</h3>
<p>If you don&#8217;t want equal values on all four sides, then you can specify each side individually:</p>
<pre name="code" class="css">
padding-top: 1px;
padding-right: 2px;
padding-bottom: 3px;
padding-left: 4px;

border-top-width: 1px;
border-right-width: 2px;
border-bottom-width: 3px;
border-left-width: 4px;

margin-top: 1px;
margin-right: 2px;
margin-bottom: 3px;
margin-left: 4px;
</pre>
<h3>The shortcut (like clockwork)</h3>
<p>However this seems to be quite a hassle typing out each property, so you&#8217;ll find it&#8217;s much easier to use the following shorthand, which is in this order: top, right, bottom, left (think of the hands going clockwise around a clock).  The following is equivalent to the above code:</p>
<pre name="code" class="css">
padding: 1px 2px 3px 4px;
border-width: 1px 2px 3px 4px;
margin: 1px 2px 3px 4px;
</pre>
<h3>Other shorthands</h3>
<p>This is the style I find myself writing in most often, but there are two other shorthand styles you should be aware of:</p>
<pre name="code" class="css">
padding: 1px 2px 3px;  /* top, left/right, bottom */
padding: 1px 2px;      /* top/bottom, left/right */
</pre>
<h3>Summary</h3>
<p>In short, there are various ways to define the padding, border, and margin on an element.  Here&#8217;s a recap, with padding used as an example:</p>
<pre name="code" class="css">
padding: 1px;              /* 1 value: top/right/bottom/left     */
padding: 1px 2px;          /* 2 values: top/bottom, left/right   */
padding: 1px 2px 3px;      /* 3 values: top, left/right, bottom  */
padding: 1px 2px 3px 4px;  /* 4 values: top, right, bottom, left */
</pre>
]]></content:encoded>
			<wfw:commentRss>http://davidbcalhoun.com/2010/a-clockwork-box/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A primer on CSS colors</title>
		<link>http://davidbcalhoun.com/2009/a-primer-on-css-colors</link>
		<comments>http://davidbcalhoun.com/2009/a-primer-on-css-colors#comments</comments>
		<pubDate>Wed, 30 Dec 2009 05:17:41 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[hex]]></category>
		<category><![CDATA[rgb]]></category>
		<category><![CDATA[rgba]]></category>
		<category><![CDATA[web safe]]></category>

		<guid isPermaLink="false">http://davidbcalhoun.com/?p=85</guid>
		<description><![CDATA[Color keywords Example usage: // Example body { color: red; } // Generalization (not actual code) body { color: color_name; } Because color names are easy to remember, they&#8217;re handy for getting quick results, especially while doing rapid prototyping. W3C&#8217;s CSS1 recommendation first mentioned 16 color keywords that you can use: aqua, black, blue, fuchsia, [...]]]></description>
			<content:encoded><![CDATA[<h3>Color keywords</h3>
<p>Example usage:</p>
<pre name="code" class="css">// Example
body { color: red; }

// Generalization (not actual code)
body { color: color_name; }</pre>
<p>Because color names are easy to remember, they&#8217;re handy for getting quick results, especially while doing rapid prototyping.</p>
<p><a href="http://www.w3.org/TR/CSS1/#color-units">W3C&#8217;s CSS1 recommendation</a> first mentioned 16 color keywords that you can use: <em>aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow</em>:</p>
<table>
<tr>
<th>Color</th>
<th>Hexadecimal</th>
<th>Color</th>
<th>Hexadecimal</th>
<th>Color</th>
<th>Hexadecimal</th>
<th>Color</th>
<th>Hexadecimal</th>
</tr>
<tr>
<td>aqua / cyan</td>
<td style="background:#0FF; color:#000; font-family:monospace;">#00FFFF</td>
<td>gray</td>
<td style="background:#808080; color:#FFF; font-family:monospace;">#808080</td>
<td>navy</td>
<td style="background:#000080; color:#FFF; font-family:monospace;">#000080</td>
<td>silver</td>
<td style="background:#C0C0C0; color:#000; font-family:monospace;">#C0C0C0</td>
</tr>
<tr>
<td>black</td>
<td style="background:#000; color:#FFF; font-family:monospace;">#000000</td>
<td>green</td>
<td style="background:#008000; color:#FFF; font-family:monospace;">#008000</td>
<td>olive</td>
<td style="background:#808000; color:#FFF; font-family:monospace;">#808000</td>
<td>teal</td>
<td style="background:#008080; color:#fff; font-family:monospace;">#008080</td>
</tr>
<tr>
<td>blue</td>
<td style="background:#00F; color:#FFF; font-family:monospace;">#0000FF</td>
<td>lime</td>
<td style="background:#0F0; color:#000; font-family:monospace;">#00FF00</td>
<td>purple</td>
<td style="background:#800080; color:#FFF; font-family:monospace;">#800080</td>
<td>white</td>
<td style="background:#FFF; color:#000; font-family:monospace;">#FFFFFF</td>
</tr>
<tr>
<td>fuchsia / magenta</td>
<td style="background:#F0F; color:#000; font-family:monospace;">#FF00FF</td>
<td>maroon</td>
<td style="background:#800000; color:#FFF; font-family:monospace;">#800000</td>
<td>red</td>
<td style="background:#F00; color:#FFF; font-family:monospace;">#FF0000</td>
<td>yellow</td>
<td style="background:#FF0; color:#000; font-family:monospace;">#FFFF00</td>
</tr>
</table>
<p>(color table from <a href="http://en.wikipedia.org/wiki/Web_colors">Wikipedia</a>)</p>
<p><a href="http://www.w3.org/TR/CSS2/syndata.html#keywords">CSS2</a> officially mapped the colors to recommended hex values and also added the color orange.  <a href="http://www.w3.org/TR/css3-color/#html4">CSS3</a> removed orange, presumably because having 17 colors was aesthetically unpleasing in a binary world?</p>
<p>In addition to these 16 &#8220;official&#8221; colors, there&#8217;s <a href="http://www.w3schools.com/css/css_colornames.asp">even more unofficial color names</a> you can use that appear to be supported in all the major browsers.</p>
<h3>RGB values</h3>
<p>Example usage:</p>
<pre name="code" class="css">// Example
body { color: rgb(255,0,0); }

// Generalization (not actual code)
body { color: rgb(red [integer 0-255], green [integer 0-255], blue [integer 0-255]); }</pre>
<p>For this section it&#8217;s very handy to know a bit about <a href="http://en.wikipedia.org/wiki/Color_theory">color theory</a>, particularly these facts:</p>
<ul>
<li>all colors can be made from a combination of red, green, and blue (RGB) as the primary colors</li>
<li>in light (additive color mixing), the absence of all color results in the color black</li>
<li>in light (additive color mixing), the mixing of red, green, and blue in equal amounts results in the color white</li>
</ul>
<p>With the rgb attribute, we specify the amount of each color we want with an integer from 0 to 255.  Here we can see both black and white expressed as rgb values:</p>
<p>Black:<br />
<span class="small-box" style="background-color: rgb(0,0,0);"></span>rgb(0,0,0)</p>
<p>White:<br />
<span class="small-box" style="background-color: rgb(255,255,255);"></span>rgb(255,255,255)</p>
<p>Also note that if all three values are equal, there is no color that predominates and the result is a shade of gray.</p>
<p>Dark gray:</p>
<p><span class="small-box" style="background-color: rgb(30,30,30);"></span>rgb(30,30,30)</p>
<p>A lighter shade of gray:</p>
<p><span class="small-box" style="background-color: rgb(200,200,200);"></span>rgb(200,200,200)</p>
<p>And of course we can favor only one color, which in this case gives us a full red, with no green or blue:</p>
<p><span class="small-box" style="background-color: rgb(255,0,0);"></span>rgb(255,0,0)</p>
<p>You may have guessed that we can also use percentage values to represent the same color:</p>
<p><span class="small-box" style="background-color: rgb(100%, 0%, 0%);"></span>rgb(100%, 0%, 0%)</p>
<h3>RGBA values</h3>
<pre name="code" class="css">// Example
body { color: rgba(255,0,0,0.5); }

// Generalization (not actual code)
body { color: rgb(red [integer 0-255], green [integer 0-255], blue [integer 0-255], alpha transparency [float 0-1]); }</pre>
<p><a href="http://www.w3.org/TR/css3-color/#rgba-color">CSS3</a> introduced rgba, which is in every way similar to rgb, except for the addition of a fourth value, alpha opacity, which gives us control over the transparency of the color.</p>
<p>So the equivalent full red we have above would look like this (no transparency):</p>
<p><span class="small-box" style="background-color: rgba(255, 0, 0, 1);"></span>rgba(255, 0, 0, 1)</p>
<p><span class="small-box" style="background-color: rgba(100%, 0%, 0%, 1);"></span>rgba(100%, 0%, 0%, 1)</p>
<p>And the same color, only now semitransparent:</p>
<p><span class="small-box" style="background-color: rgba(255, 0, 0, 0.5);"></span>rgba(255, 0, 0, 0.5)</p>
<p><span class="small-box" style="background-color: rgba(100%, 0%, 0%, 0.5);"></span>rgba(100%, 0%, 0%, 0.5)</p>
<h3>Hex values</h3>
<p>Example usage:</p>
<pre name="code" class="css">// Example
body { color: #ff0000; }

// Generalization (not actual code)
body { color: #rrggbb; }</pre>
<p>Hex values are probably the most common out of all of the ways to represent colors in CSS.  But I included them last &#8211; what gives?  It seems to me that the rgb value should logically be explained first.  The hex value is just a hex version (and thus slightly more confusing version) of expressing rgb values.</p>
<p>For this section you ought to know the basics of <a href="http://en.wikipedia.org/wiki/Hexadecimal">hexadecimal numbers</a>.  In particular, the fact that hexadecimals are base 16 and use letters a-f to represent numbers beyond our conventional base 10 range.</p>
<p>The hex value starts with a hash (#) and is followed by six numbers and/or letters.  This is simply our three color values again: red, green, blue, with each color allowed two digits.</p>
<p>We express our solid red color like this:</p>
<p><span class="small-box" style="background-color: #ff0000;"></span>#ff0000</p>
<p>As long as you can convert between decimal and hexadecimal (there&#8217;s <a href="http://www.google.com/search?aq=f&#038;ie=UTF-8&#038;q=decimal+to+hex">a few free tools online</a>), it&#8217;s relatively easy to convert between rgb and hex color values.  Just keep in mind that the first 16 hex values are preceded by a zero (0 becomes 00, 1 becomes 01, 10 becomes 0a, 11 becomes 0b, etc.)</p>
<h3>Shorthand hex</h3>
<p>Example usage:</p>
<pre name="code" class="css">// Example
body { color: #f00; }

// Generalization (not actual code)
body { color: #rgb; }</pre>
<p>Last but not least, if each rgb value has a repeating value, you can simply omit the repeating value.  In the case above each of our color values was repeating (red = ff, green = 00, blue = 00), so we simply drop the repeating digit from each color and cut three bytes from our code:</p>
<p><span class="small-box" style="background-color: #f00;"></span>#f00</p>
<h3>A note on web-safe colors</h3>
<p><a href="http://en.wikipedia.org/wiki/Web_colors#Web-safe_colors">Web safe colors</a> were a recommended subset of about 256 colors with which to design websites.  The rationale for solely using them for web design was for rendering consistency, so even users with very limited displays could see the page as it was intended to be displayed.</p>
<p>The concept of a &#8220;web safe&#8221; color was becoming obsolete even in 1997 or so, when I started making my personal website on AOL.  It&#8217;s safe to say that the vast majority of users today are now able to view webpages with at least 16 million colors (256*256*256).</p>
<p>But this doesn&#8217;t mean we shouldn&#8217;t be concerned about colors.  Apart from pure aesthetics, in the area of accessibility it&#8217;s often mentioned that users with colorblindness find certain combinations of colors difficult to see.  So keep this in the back of your head when you go crazy with those wild color schemes!</p>
<h3>More info</h3>
<p>Probably the best way to learn how to use these color values is to actually try them on your website, however you might also find the following links useful.</p>
<div class="website"><a href="http://colorschemedesigner.com/"><img src="http://davidbcalhoun.com/wp-content/uploads/2009/12/color-scheme-designer.png" alt="Color Scheme Designer" title="Color Scheme Designer" width="300"/></a>
<div>
<p><a href="http://colorschemedesigner.com/">Color Scheme Designer</a> is a nice tool for finding several colors that (theoretically) should go well together.  It&#8217;s a nice place to go when building a website from the ground-up.</p>
<p><a href="http://colorschemedesigner.com/">http://colorschemedesigner.com/</a></p>
</div>
</div>
<div class="website"><a href="http://schlaeps.com/mootools/gradient-creator/"><img src="http://davidbcalhoun.com/wp-content/uploads/2009/12/mootols-webkit-gradient.png" alt="Color Scheme Designer" title="Color Scheme Designer" width="300"/></a>
<div>
<p><a href="http://schlaeps.com/mootools/gradient-creator/">Jonathan Schlaepfer</a> made a nice helper tool built in Mootols for creating webkit gradients.  Gradients wasn&#8217;t the subject of this entry, but it&#8217;s helpful to see a nice visualization of rgb values corresponding to the hex values.</p>
<p><a href="http://schlaeps.com/mootools/gradient-creator/">http://schlaeps.com/mootools/gradient-creator/</a></p>
</div>
</div>
<p><a href="http://en.wikipedia.org/wiki/Web_colors">Wikipedia: Web colors</a></p>
<p><a href="http://www.w3schools.com/html/html_colors.asp">HTML Colors</a></p>
]]></content:encoded>
			<wfw:commentRss>http://davidbcalhoun.com/2009/a-primer-on-css-colors/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IE Mobile 6.12 problem: browser ignores the specificity of CSS display styles</title>
		<link>http://davidbcalhoun.com/2009/ie-mobile-6-12-problem-browser-ignores-the-specificity-of-css-display-styles</link>
		<comments>http://davidbcalhoun.com/2009/ie-mobile-6-12-problem-browser-ignores-the-specificity-of-css-display-styles#comments</comments>
		<pubDate>Tue, 01 Sep 2009 04:41:48 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[6.12]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[display]]></category>
		<category><![CDATA[ie6]]></category>
		<category><![CDATA[iemobile]]></category>
		<category><![CDATA[inline]]></category>
		<category><![CDATA[inline-block]]></category>

		<guid isPermaLink="false">http://davidbcalhoun.com/?p=3</guid>
		<description><![CDATA[UPDATE: I found that the problem is actually that inline-block is completely unsupported in this version of IE Mobile, and is likely also unsupported in IE Mobile 7, which is also based on IE4. This is in contrast to desktop IE6, where inline-block is supported on elements that are natively inline (span, em, etc.). Just [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE:</strong> I found that the problem is actually that inline-block is completely unsupported in this version of IE Mobile, and is likely also unsupported in IE Mobile 7, which is also based on IE4.  This is in contrast to desktop IE6, where inline-block is supported on elements that are natively inline (span, em, etc.).</p>
<p>Just found this today, for what it&#8217;s worth.  If you&#8217;re unlucky enough to be working with older Windows Mobile phones you have probably realized that the browser is based on IE6, which all the desktop web developers notoriously complain about constantly.</p>
<p>Though the mobile version of IE6 has most of the same issues as its desktop counterpart, IEMobile introduces some new random problems.  And in most cases there&#8217;s no handy web resources to help you out, since almost everyone develops for the desktop.</p>
<p>This particular IEMobile quirk is a specificity problem.  We have a parent element styled with display: block and the child element is styled with display: inline-block or display: inline.  We&#8217;ve made the child CSS selector more specific so it <em>should</em> override the parent:</p>
<pre name="code" class="css">.parent { display: block; }
.parent .child { display: inline-block; }</pre>
<p>This works on the desktop version of IE6!  But not in IEMobile 6.12, where the child element is still displayed as a block.  The same thing happens when we change the &#8220;.parent .child&#8221; style to &#8220;display: inline;&#8221;, but interestingly not when we change it to &#8220;display: none;&#8221;, where the style is correctly recognized and applied.  Doh!</p>
<p>And FYI: I checked and found that this bug is <em>not</em> occurring on IEMobile 8.12</p>
]]></content:encoded>
			<wfw:commentRss>http://davidbcalhoun.com/2009/ie-mobile-6-12-problem-browser-ignores-the-specificity-of-css-display-styles/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
