<?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>San Bei Ji &#187; webdev</title>
	<atom:link href="http://www.sanbeiji.com/archives/tag/webdev/feed" rel="self" type="application/rss+xml" />
	<link>http://www.sanbeiji.com</link>
	<description>三杯雞好吃!</description>
	<lastBuildDate>Wed, 18 Jan 2012 17:57:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>SVG and MathML in HTML5</title>
		<link>http://www.sanbeiji.com/archives/1243</link>
		<comments>http://www.sanbeiji.com/archives/1243#comments</comments>
		<pubDate>Wed, 08 Dec 2010 04:51:09 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[developingwithhtml5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[MathML]]></category>
		<category><![CDATA[science]]></category>
		<category><![CDATA[standards]]></category>
		<category><![CDATA[svg]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[webstandards]]></category>

		<guid isPermaLink="false">http://www.sanbeiji.com/?p=1243</guid>
		<description><![CDATA[The next article in the Developing with HTML5 series. Pick a flower on Earth and you move the farthest star. —Paul Dirac Scalable Vector Graphics (SVG) and MathML are XML applications that are widely used in scientific contexts. SVG is &#8230; <a href="http://www.sanbeiji.com/archives/1243">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_brick-red" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.sanbeiji.com%252Farchives%252F1243%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22SVG%20and%20MathML%20in%20HTML5%22%20%7D);"></div>
<p><em>The next article in the <a href="http://www.sanbeiji.com/archives/tag/developingwithhtml5">Developing with HTML5 series</a>.</em></p>
<blockquote><p>Pick a flower on Earth and you move the farthest star. </p>
<p><cite>—Paul Dirac</cite></p></blockquote>
<p><a href="http://en.wikipedia.org/wiki/Scalable_Vector_Graphics">Scalable Vector Graphics</a> (SVG) and <a href="http://www.w3.org/Math/">MathML</a> are XML applications that are widely used in scientific contexts. SVG is used to draw vector graphics, and is frequently found in visualization libraries such as <a href="http://vis.stanford.edu/protovis/">ProtoVis</a>. MathML is used to describe the presentation and meaning of mathematical formul&aelig;. They are very easy to work with in a programmatic sense, because they are XML-based and therefore just text, and yet they are capable of rendering beautiful information in supporting web browsers.</p>
<div id="attachment_1245" class="wp-caption alignright" style="width: 150px"><a href="http://www.sanbeiji.com/wp-content/uploads/2010/12/Dirac.gif" rel="lightbox[1243]"><img src="http://www.sanbeiji.com/wp-content/uploads/2010/12/Dirac.gif" alt="Paul Dirac, who loved the maths." title="Dirac" width="140" height="198" class="size-full wp-image-1245" /></a><p class="wp-caption-text">Paul Dirac, who loved the maths.</p></div>
<p>The idea behind XHTML was to move the web toward extensibility (the X in XHTML), where a web browser markup language could be seeded with bits of other XML applications by declaring a namespace and letting things coexist. The problem with that plan was that XML parsers were required to be extremely fussy, to the point that if a problem was detected the browser should render an error message. Browsers don&#8217;t work that way. Instead, they forgive your human or computer errors and render the page as best as their little hearts can.</p>
<p>In the beginning of the process, HTML5 was not extensible, and to this day it remains opposed to the whole namespace idea. But SVG and MathML are highly popular and useful XML applications that deserve a place within the HTML5 spec. And so shall it be: <code>&lt;svg&gt;</code> and <code>&lt;math&gt;</code> are the opening volleys in inserting SVG and MathML into your HTML5 document tree. Any elements that are children of the SVG and MathML specs are valid and functional child elements of the <code>&lt;svg&gt;</code> and <code>&lt;math&gt;</code> elements respectively. No need to declare a namespace. You&#8217;re done. Thank you.</p>
<p>Now this is not to say that the idea of inserting these XML applications within the HTML5 spec is not without some controversy. What about <a href="http://en.wikipedia.org/wiki/List_of_XML_markup_languages">other XML applications</a> and XHTML extensions such as <a href="http://en.wikipedia.org/wiki/RDFa">RDFa</a>, <a href="http://en.wikipedia.org/wiki/Chemical_Markup_Language">CML</a>, and <a href="http://www.musicmarkup.info/">MML</a>? CML (Chemical Markup Language) and MML (Music Markup Language) are indeed common, but within specific application contexts. They are not supported yet by any web browser (whereas MathML and SVG are well supported.) RDFa on the other hand is a more political issue: More on that whole mess in a later post&#8230; <img src='http://www.sanbeiji.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>So in short, SVG and MathML are supported objects within HTML5 because they are widely deployed in existing web browsers, and they are very useful – particularly to those of us in the science industry charged with representing scientific information on the web. Let&#8217;s look at how to get started. First, an SVG example – simply start your SVG block using the <code>&lt;svg&gt;</code> element and drop your SVG markup within:</p>
<p><code>&lt;!DOCTYPE&nbsp;html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&nbsp;&nbsp;&lt;meta&nbsp;charset=&quot;utf-8&quot;&gt;<br />
&nbsp;&nbsp;&lt;title&gt;The Sun in SVG&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&nbsp;&nbsp;&lt;h1&gt;The Sun in SVG&lt;/h1&gt;<br />
&nbsp;&nbsp;&lt;svg&nbsp;style=&quot;width:300px;&nbsp;height:300px;&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&lt;radialGradient&nbsp;cx=&quot;0.5&quot;&nbsp;cy=&quot;0.5&quot;&nbsp;r=&quot;0.5&quot;&nbsp;id=&quot;g&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;stop&nbsp;stop-color=&quot;rgb(255,&nbsp;255,&nbsp;0)&quot;&nbsp;offset=&quot;0&quot;/&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;stop&nbsp;stop-color=&quot;rgb(255,&nbsp;221,&nbsp;51)&quot;&nbsp;offset=&quot;0.6917&quot;/&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;stop&nbsp;stop-color=&quot;rgb(254,&nbsp;140,&nbsp;25)&quot;&nbsp;offset=&quot;0.7083&quot;/&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;stop&nbsp;stop-color=&quot;rgb(0,&nbsp;0,&nbsp;0)&quot;&nbsp;offset=&quot;1&quot;/&gt;<br />
&nbsp;&nbsp;&nbsp;&lt;/radialGradient&gt;<br />
&nbsp;&nbsp;&nbsp;&lt;rect&nbsp;width=&quot;100%&quot;&nbsp;height=&quot;100%&quot;&nbsp;fill=&quot;url(#g)&quot;/&gt;<br />
&nbsp;&nbsp;&lt;/svg&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</code></p>
<p><a href="/tests/html5_svg_mathml_example.html">Here&#8217;s a live example</a> that will work in browsers that support SVG and MathML in HTML5. (Try it in the Firefox 4 beta.) Or if you aren&#8217;t one of those early-adopting browser users that are used to living dangerously, then please refer to the perfectly safe reference image below:</p>
<div id="attachment_1246" class="wp-caption aligncenter" style="width: 310px"><img src="http://www.sanbeiji.com/wp-content/uploads/2010/12/svgsun.png" alt="Reference rendering of the sun in SVG." width="300" height="300" class="alignnone size-full wp-image-1246" /><p class="wp-caption-text">Reference rendering of the sun in SVG.</p></div>
<p>To learn more about SVG, check out the <a href="http://www.w3schools.com/svg/default.asp">w3schools SVG tutorial</a> for starters.  While SVG is supported in basic forms in Chrome, Safari, and Firefox, only Firefox 4 (currently in beta) supports embedding SVG natively in HTML5. But Chrome will follow soon, followed by IE9, Safari, and eventually (hopefully) Opera.</p>
<p>MathML is equally straightforward, using the <code>&lt;math&gt;</code> element as the opener:</p>
<p><code>&lt;!DOCTYPE html&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&nbsp;&nbsp;&lt;meta charset=&quot;utf-8&quot;&gt;<br />
&nbsp;&nbsp;&lt;title&gt;The Dirac &amp;delta;-function&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&nbsp;&nbsp;&lt;h1&gt;The Dirac &amp;delta;-function&lt;/h1&gt;<br />
&nbsp;&nbsp;&lt;math style=&quot;font-size:200%&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;mrow&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;msubsup&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mo&gt;&amp;int;&lt;/mo&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mrow&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mrow&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mo&gt;-&lt;/mo&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mi&gt;&amp;infin;&lt;/mi&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/mrow&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/mrow&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mi&gt;&amp;infin;&lt;/mi&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/msubsup&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mrow&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mi&gt;f&lt;/mi&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mi&gt;&amp;delta;&lt;/mi&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/mrow&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/mrow&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;mo&gt;=&lt;/mo&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;mrow&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mo&gt;f&lt;/mo&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mfenced&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mrow&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mn&gt;0&lt;/mn&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/mrow&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/mfenced&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/mrow&gt;<br />
&nbsp;&nbsp;&lt;/math&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</code></p>
<p>Compare to the reference rendering below, or <a href="/tests/html5_svg_mathml_example.html">check out the live example</a>.</p>
<div id="attachment_1247" class="wp-caption alignnone" style="width: 194px"><a href="http://www.sanbeiji.com/wp-content/uploads/2010/12/dirac-delta.png" rel="lightbox[1243]"><img src="http://www.sanbeiji.com/wp-content/uploads/2010/12/dirac-delta.png" alt="The Dirac delta function rendered from MathML in Firefox 4 beta" title="dirac-delta" width="184" height="55" class="size-full wp-image-1247" /></a><p class="wp-caption-text">The Dirac delta function rendered from MathML in Firefox 4 beta</p></div>
<p>Again, currently Firefox 4 beta is the only close-to-shipping browser that supports this. But it is expected to come to all major modern browsers in 2010/2011, including IE9, Safari, Opera, and Google Chrome. To learn more about how to construct MathML, check out <a href="http://reference.wolfram.com/mathematica/XML/tutorial/MathML.html">Mathematica&#8217;s MathML tutorial</a>.</p>
<p>In short, it&#8217;s an easy trip to embed SVG and MathML in HTML5. No namespaces are required. The trade-off is less extensibility, but if you need extensibility back there&#8217;s an XML flavor of HTML5, appropriately titled <a href="http://blog.whatwg.org/xhtml5-in-a-nutshell">XHTML5</a>. In the meantime, start looking for ways to leverage SVG and MathML in the coming months as capable browsers start coming online! While this is indeed a bit on the bleeding-edge side of things, web browsers are beginning to implement these features and I expect over the next year or two the practice of embedding SVG and MathML markup in HTML5 web pages will become entirely commonplace within the scientific community.</p>

]]></content:encoded>
			<wfw:commentRss>http://www.sanbeiji.com/archives/1243/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Exploring New HTML5 Elements</title>
		<link>http://www.sanbeiji.com/archives/1237</link>
		<comments>http://www.sanbeiji.com/archives/1237#comments</comments>
		<pubDate>Fri, 03 Dec 2010 18:19:36 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[developingwithhtml5]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[semantics]]></category>
		<category><![CDATA[structure]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://www.sanbeiji.com/?p=1237</guid>
		<description><![CDATA[The next article in the Developing with HTML5 series. Nothing endures but change. —Heraclitus The HTML5 draft specification includes many new elements and attributes for enhanced structural and semantic clarity. Most of the old elements still exist too, and you &#8230; <a href="http://www.sanbeiji.com/archives/1237">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_brick-red" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.sanbeiji.com%252Farchives%252F1237%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Exploring%20New%20HTML5%20Elements%22%20%7D);"></div>
<p><em>The next article in the <a href="http://www.sanbeiji.com/archives/tag/developingwithhtml5">Developing with HTML5 series</a>.</em></p>
<blockquote><p>Nothing endures but change.</p>
<p><em>—Heraclitus</em></p></blockquote>
<p>The HTML5 draft specification includes many new elements and attributes for enhanced structural and semantic clarity. Most of the old elements still exist too, and you can still use them if you like. But the new elements will serve to make your markup clearer, more compact, and more functional in modern web browsers. Let&#8217;s take a look at some of these elements and what they mean for web developers in scientific contexts. For starters, here&#8217;s a list of the new elements, along with links to the relevant points in the specification:</p>
<div id="attachment_358" class="wp-caption alignright" style="width: 204px"><a href="http://www.flickr.com/photos/cote/146504243/" title="Heraclitus by cote, on Flickr"><img src="http://farm1.static.flickr.com/56/146504243_73bd332c0a_m.jpg" width="194" height="240" alt="Heraclitus" /></a><p class="wp-caption-text">Heraclitus by cote on Flickr</p></div>
<ul>
<li><a href="http://dev.w3.org/html5/spec/forms.html#the-datalist-element"><code>datalist</code></a></li>
<li><a href="http://dev.w3.org/html5/spec/forms.html#the-keygen-element"><code>keygen</code></a></li>
<li><a href="http://dev.w3.org/html5/spec/forms.html#the-output-element"><code>output</code></a></li>
<li><a href="http://dev.w3.org/html5/spec/text-level-semantics.html#the-ruby-element"><code>ruby</code></a>, <a href="http://dev.w3.org/html5/spec/text-level-semantics.html#the-rt-element"><code>rt</code></a>, and <a href="http://dev.w3.org/html5/spec/text-level-semantics.html#the-rp-element"><code>rp</code></a></li>
<li><a href="http://dev.w3.org/html5/spec/text-level-semantics.html#the-wbr-element"><code>wbr</code></a></li>
<li><a href="http://www.w3.org/TR/html5/embedded-content-0.html#the-embed-element"><code>embed</code></a></li>
<li><a href="http://www.w3.org/TR/html5/interactive-elements.html#the-command"><code>command</code></a></li>
<li><a href="http://www.w3.org/TR/html5/interactive-elements.html#the-details-element"><code>details</code></a></li>
<li><a href="http://www.w3.org/TR/html5/semantics.html#the-article-element"><code>article</code></a></li>
<li><a href="http://www.w3.org/TR/html5/semantics.html#the-aside-element"><code>aside</code></a></li>
<li><a href="http://www.w3.org/TR/html5/semantics.html#the-figure-element"><code>figure</code></a></li>
<li><a href="http://www.w3.org/TR/html5/semantics.html#the-footer-element"><code>footer</code></a></li>
<li><a href="http://www.w3.org/TR/html5/semantics.html#the-header-element"><code>header</code></a></li>
<li><a href="http://www.w3.org/TR/html5/semantics.html#the-hgroup-element"><code>hgroup</code></a></li>
<li><a href="http://www.w3.org/TR/html5/semantics.html#the-nav-element"><code>nav</code></a></li>
<li><a href="http://www.w3.org/TR/html5/semantics.html#the-section-element"><code>section</code></a></li>
<li><a href="http://www.w3.org/TR/html5/text-level-semantics.html#the-mark-element"><code>mark</code></a></li>
<li><a href="http://www.w3.org/TR/html5/text-level-semantics.html#the-meter-element"><code>meter</code></a></li>
<li><a href="http://www.w3.org/TR/html5/text-level-semantics.html#the-progress-element"><code>progress</code></a></li>
<li><a href="http://www.w3.org/TR/html5/text-level-semantics.html#the-time-element"><code>time</code></a></li>
<li><a href="http://www.w3.org/TR/html5/the-canvas-element.html#the-canvas-element"><code>canvas</code></a></li>
<li><a href="http://www.w3.org/TR/html5/video.html#video"><code>video</code></a></li>
</ul>
<h3>A first glance at HTML5 structure</h3>
<p>The first elements we should look at are the structural ones: </p>
<p><code>article</code>, <code>aside</code>, <code>figcaption</code>, <code>figure</code>, <code>footer</code>, <code>header</code>, <code>hgroup</code>, <code>nav</code>, and <code>section</code>. Take a look at those names for a moment. Think how many times you&#8217;ve formed your markup in a fashion resembling something like the following code:</p>
<p><code>&lt;div&nbsp;<b>id=&quot;header&quot;</b>&gt;<br />
&nbsp;&nbsp;&lt;h1&gt;Tales&nbsp;of&nbsp;Woe&lt;/h1&gt;<br />
&nbsp;&nbsp;&lt;p&nbsp;class=&quot;tagline&quot;&gt;The&nbsp;neverending&nbsp;saga&nbsp;continues...&lt;/p&gt;<br />
&nbsp;&nbsp;&lt;div&nbsp;<b>id=&quot;nav&quot;</b>&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;h2&gt;Navigation&lt;/h2&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;a&nbsp;href=&quot;one.html&quot;&gt;Page&nbsp;One&lt;/a&gt;&lt;/li&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;a&nbsp;href=&quot;two.html&quot;&gt;Page&nbsp;Two&lt;/a&gt;&lt;/li&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;a&nbsp;href=&quot;three.html&quot;&gt;Page&nbsp;the&nbsp;Third&lt;/a&gt;&lt;/li&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
&nbsp;&nbsp;&lt;/div&gt;<br />
&lt;/div&gt;<br />
&lt;div&nbsp;<b>class=&quot;article&quot;</b>&gt;<br />
&nbsp;&nbsp;&lt;h2&gt;The&nbsp;Stagnant&nbsp;Staircase&lt;/h2&gt;<br />
&nbsp;&nbsp;&lt;p&gt;It was a dark and stormy night. She didn&#x27;t notice the vase by the banister as she walked past it, holding the wilted flowers in stale and murky water. The only thing she knew was that the nightmares had to end, and that they would end tonight...&lt;/p&gt;<br />
&lt;/div&gt;<br />
&lt;div&nbsp;<b>id=&quot;footer&quot;</b>&gt;<br />
&nbsp;&nbsp;&lt;p&gt;&copy;2010&nbsp;In&nbsp;Your&nbsp;Nightmares&nbsp;Productions.&lt;/p&gt;<br />
&lt;/div&gt;</code></p>
<p>In particular, I&#8217;d like to direct your attention to the ID and class attributes for header, article, and footer. These are major structural components that are common in everyday markup. Use of these semantic structures is so common, that it made sense to construct elements around them. Here is the same code as the above, refactored in HTML5:</p>
<p><code><b>&lt;header&gt;</b><br />
&nbsp;&nbsp;&lt;h1&gt;Tales&nbsp;of&nbsp;Woe&lt;/h1&gt;<br />
&nbsp;&nbsp;&lt;p&nbsp;class=&quot;tagline&quot;&gt;The&nbsp;neverending&nbsp;saga&nbsp;continues...&lt;/p&gt;<br />
&nbsp;&nbsp;<b>&lt;nav&gt;</b><br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;h2&gt;Navigation&lt;/h2&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;a&nbsp;href=&quot;one.html&quot;&gt;Page&nbsp;One&lt;/a&gt;&lt;/li&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;a&nbsp;href=&quot;two.html&quot;&gt;Page&nbsp;Two&lt;/a&gt;&lt;/li&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;a&nbsp;href=&quot;three.html&quot;&gt;Page&nbsp;the&nbsp;Third&lt;/a&gt;&lt;/li&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
&nbsp;&nbsp;<b>&lt;/nav&gt;</b><br />
<b>&lt;/header&gt;</b><br />
<b>&lt;article&gt;</b><br />
&nbsp;&nbsp;&lt;h2&gt;The&nbsp;Stagnant&nbsp;Staircase&lt;/h2&gt;<br />
&nbsp;&nbsp;&lt;p&gt;It was a dark and stormy night. She didn&#x27;t notice the vase by the banister as she walked past it, holding the wilted flowers in stale and murky water. The only thing she knew was that the nightmares had to end, and that they would end tonight...&lt;/p&gt;<br />
<b>&lt;/article&gt;</b><br />
<b>&lt;footer&gt;</b><br />
&nbsp;&nbsp;&lt;p&gt;©2010&nbsp;In&nbsp;Your&nbsp;Nightmares&nbsp;Productions.&lt;/p&gt;<br />
<b>&lt;/footer&gt;</b></code></p>
<p>In the revised HTML5 version, things are much clearer to read. Your eye can readily follow where the beginning and end of the structural blocks are, because they have structural names such as <code>article</code> and <code>footer</code> instead of just generic <code>div</code> elements with nondescript element closings.</p>
<p>The specification defines <code>header</code> as &#8220;a group of introductory or navigational aids.&#8221; This could mean navigation, tag lines, section headings, logos, etc. In this example, we use this element to define the masthead of a page, but it could just as easily be a child of a navigation element or an article too &#8211; if that&#8217;s what the content semantically would require.</p>
<p>The <code>article</code> element represents a defined, distributable piece of content. This might be a press release, a journal article, a blog post, or even a status message such as we&#8217;d see on Twitter. We used it here to begin our piece of pulp fiction. (I&#8217;m sure there&#8217;s more to the story &#8211; perhaps at the next NaNoWriMo I&#8217;ll use that as a germ for an actual story&#8230;)</p>
<h3>Heading groups</h3>
<p>Oh, one more thing about this section that we should address, and here&#8217;s where things get interesting: the tagline. Right now we have a paragraph tag with a class of tagline. And if we&#8217;d like to keep that formatting in place, that&#8217;s fine. However there&#8217;s a new construct in HTML5 that we can leverage, so let&#8217;s take a look at the <code>hgroup</code> element:</p>
<p><code>&lt;hgroup&gt;<br />
&nbsp;&nbsp;&lt;h1&gt;Tales of Woe&lt;/h1&gt;<br />
&nbsp;&nbsp;&lt;h2&gt;The neverending saga continues...&lt;/h2&gt;<br />
&lt;/hgroup&gt;</code></p>
<p>Here what we&#8217;ve done is to change the tagline paragraph into an <code>h2</code> element, and wrap the <code>h1</code> and <code>h2</code> elements inside of an <code>hgroup</code>. The <code>hgroup</code> element is a heading, and can only contain two or more of <code>h1</code> through <code>h6</code>.</p>
<h3>Sectioning off headings</h3>
<p>Furthermore, you can use the <code>section</code> element to help structure your document. In a nutshell, consider that any heading within a <code>section</code> is one level lower than headings of the same face value outside of it. Consider the following markup:</p>
<p><code>&lt;section&gt;<br />
&nbsp;&nbsp;&lt;h1&gt;Homininae&lt;/h1&gt;<br />
&nbsp;&nbsp;&lt;section&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Gorillini&lt;/h1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;section&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Gorilla&nbsp;gorilla&lt;/h1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;section&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Gorilla&nbsp;gorilla&nbsp;gorilla&lt;/h1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Gorilla&nbsp;gorilla&nbsp;diehli&lt;/h1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/section&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Gorilla&nbsp;beringei&lt;/h1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;section&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Gorilla&nbsp;beringei&nbsp;beringei&lt;/h1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Gorilla&nbsp;beringei&nbsp;graueri&lt;/h1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/section&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/section&gt;<br />
&nbsp;&nbsp;&lt;/section&gt;<br />
&nbsp;&nbsp;&lt;section&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Hominini&lt;/h1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;section&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Pan&lt;/h1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;section&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Pan&nbsp;traglodytes&lt;/h1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;section&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Pan&nbsp;troglodytes&nbsp;troglodytes&lt;/h1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Pan&nbsp;troglodytes&nbsp;verus&lt;/h1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Pan&nbsp;troglodytes&nbsp;vellerosus&lt;/h1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Pan&nbsp;troglodytes&nbsp;schweinfurthii&lt;/h1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/section&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Pan&nbsp;paniscus&lt;/h1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/section&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/section&gt;<br />
&nbsp;&nbsp;&lt;/section&gt;<br />
&nbsp;&nbsp;&lt;section&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Homo&lt;/h1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;section&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Homo&nbsp;sapiens&lt;/h1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;section&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Homo&nbsp;sapiens&nbsp;sapiens&lt;/h1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/section&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/section&gt;<br />
&nbsp;&nbsp;&lt;/section&gt;<br />
&lt;/section&gt;</code></p>
<p>These are all <code>h1</code> elements, but structurally the hierarchy is represented as so, due to the nestings of the <code>section</code> elements:</p>
<ul>
<li>Homininae
<ul>
<li>Gorillini
<ul>
<li>Gorilla gorilla
<ul>
<li>Gorilla gorilla gorilla</li>
<li>Gorilla gorilla diehli</li>
</ul>
</li>
<li>Gorilla beringei
<ul>
<li>Gorilla beringei beringei</li>
<li>Gorilla beringei graueri</li>
</ul>
</li>
</ul>
</li>
<li>Hominini
<ul>
<li>Pan
<ul>
<li>Pan traglodytes
<ul>
<li>Pan troglodytes troglodytes</li>
<li>Pan troglodytes verus</li>
<li>Pan troglodytes vellerosus</li>
<li>Pan troglodytes schweinfurthii</li>
</ul>
</li>
<li>Pan paniscus</li>
</ul>
</li>
</ul>
</li>
<li>Homo
<ul>
<li>Homo sapiens
<ul>
<li>Homo sapiens sapiens</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<h3>It&#8217;s turtle headings, all the way down</h3>
<p>In the code, we had all <code>h1</code>s, but the spec requires that the hierarchy is interpreted as shown in this list, and we can clearly see that say homo sapiens sapiens is a subheading of homo sapiens, which is in turn a subheading of homo, then finally homininae. But why does this matter? Well, consider for a moment that the HTML5 specification only allows specific headings of <code>h1</code> through <code>h6</code>. Then consider if we were to extend our taxonomic classification to encompass all mammals. We&#8217;d run out of headings before we got to homininae! In this manner, we can use the <code>h1</code> element ad infinitum within it&#8217;s own <code>section</code> elements, and if we needed we can throw in a little <code>h2</code> through <code>h6</code> if needed. If we run out, just add more <code>section</code>s.</p>
<p>A small caveat, however: Having an endless stream of <code>h1</code>s means today&#8217;s screen readers used by disabled users might have trouble dealing with the hierarchical order of your content, and there is no functional CSS or other construct currently available to work around this problem. If you have accessibility issues to contend with, stick with the traditional usage of <code>h1</code> through <code>h6</code> for now, even if you use <code>heading</code> within.</p>
<h3>Go figure</h3>
<p>The <code>figure</code> and <code>figcaption</code> elements are for inserting and captioning figures in text documents. Before, we didn&#8217;t have an effective way to mark up figure images, and certainly had to come up with creative ways to mark up captions. These elements wrap this problem up nicely.</p>
<p><code>&lt;figure&gt;<br />
&nbsp;&nbsp;&lt;img src=&quot;Viola.jpg&quot;&gt;&lt;/video&gt;<br />
&nbsp;&nbsp;&lt;figcaption&gt;This is a lovely Amati 1710 viola.&lt;/figcaption&gt;<br />
&lt;/figure&gt;</code></p>
<h3>As a side note&#8230;</h3>
<p>The only structural elements I haven&#8217;t mentioned yet is the <code>aside</code> element. The <code>aside</code> element indicates related information. It could be used for what we consider typical &#8220;sidebar&#8221; content in a web page layout, or it could be an aside in a story &#8211; such as a text box titled &#8220;learn more&#8221; in a feature news story or textbook-style article of content. This element may have it&#8217;s own headings, nav, content, and whatnot, and if it is found occurring within an <code>article</code> then it is considered related to that given article of content.</p>
<p>And that just about wraps up an introduction to HTML5 with a brief overview of the core structural and hierarchical elements. As we move forward with <a href="http://www.sanbeiji.com/tag/developingwithhtml5/">this series</a>, we&#8217;ll take a look at the other new elements mentioned above, as well as look at some of the ways HTML5 has refactored existing markup to have new meaning.</p>

]]></content:encoded>
			<wfw:commentRss>http://www.sanbeiji.com/archives/1237/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First steps with HTML5</title>
		<link>http://www.sanbeiji.com/archives/1214</link>
		<comments>http://www.sanbeiji.com/archives/1214#comments</comments>
		<pubDate>Mon, 08 Nov 2010 02:22:21 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[developingwithhtml5]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[markup]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[webstandards]]></category>

		<guid isPermaLink="false">http://www.sanbeiji.com/?p=1214</guid>
		<description><![CDATA[As I mentioned in my earlier post, HTML5 means quite a lot more than what we all understood markup to be in the HTML 4/XHTML days. At the core of the HTML5 specification however, markup is still the foundation. Let&#8217;s &#8230; <a href="http://www.sanbeiji.com/archives/1214">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_brick-red" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.sanbeiji.com%252Farchives%252F1214%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22First%20steps%20with%20HTML5%22%20%7D);"></div>
<p>As I mentioned in my <a href="http://www.sanbeiji.com/archives/1207">earlier post</a>, HTML5 means quite a lot more than what we all understood markup to be in the HTML 4/XHTML days. At the core of the HTML5 specification however, markup is still the foundation. Let&#8217;s take a quick look at some of the differences between HTML5 and it&#8217;s predecessors. But before we get too into this HTML5 series, I should mention that the principal reason I&#8217;m posting my thoughts here on the subject is to learn for myself, and secondly to document a nugget of information or two that might be useful to you all out there. Excellent stuff has been written on this subject. Go read Bruce Lawson and Remy Sharp&#8217;s book <cite><a href="https://www.amazon.com/dp/0321687299?tag=sanbeiji-20&#038;camp=213381&#038;creative=390973&#038;linkCode=as4&#038;creativeASIN=0321687299&#038;adid=1HVYDR4ARQ6GB9MCB0WV&#038;">Introducing HTML5</a></cite>, Mark Pilgrim&#8217;s <cite><a href="https://www.amazon.com/dp/0596806027?tag=sanbeiji-20&#038;camp=213381&#038;creative=390973&#038;linkCode=as4&#038;creativeASIN=0596806027&#038;adid=0MT03EQJ0MXKF4PK8668&#038;">HTML5 Up and Running</a></cite>, and Tantek Çelic&#8217;s <cite><a href="http://www.amazon.com/gp/product/0321719913?ie=UTF8&#038;tag=sanbeiji-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0321719913">HTML5 Now</a></cite>. Go read every one of these books cover to cover — I highly recommend them.</p>
<blockquote><p>It can scarcely be denied that the supreme goal of all theory is to make the irreducible basic elements as simple and as few as possible without having to surrender the adequate representation of a single datum of experience.</p>
<p><em>—Albert Einstein</em></p></blockquote>
<div id="attachment_1215" class="wp-caption alignright" style="width: 310px"><a href="http://www.sanbeiji.com/wp-content/uploads/2010/11/Einstein_and_Tagore_Berlin_14_July_1930.jpg" rel="lightbox[1214]"><img src="http://www.sanbeiji.com/wp-content/uploads/2010/11/Einstein_and_Tagore_Berlin_14_July_1930-300x259.jpg" alt="Einstein and Tagore, Berin, 1930" title="Einstein_and_Tagore_Berlin_14_July_1930" width="300" height="259" class="size-medium wp-image-1215" /></a><p class="wp-caption-text">Physicists with mad hair who most assuredly would have been totally down with HTML5.</p></div>
<p>I will now go through some of the reasoning akin to the way Pilgrim and Lawson follow in constructing the optimal basic HTML5 markup template, with my own commentary, flavor, and style thrown in just so I can acquire it in my head and hopefully help you all along with the reasoning:</p>
<p>The first line of code we see in HTML documents is the doctype. The reason why it is standard practice to use doctypes in markup, as all good web developers already know, is to trigger standards mode in web browsers. All major modern web browsers support this function, and it makes the role of a web developer much simpler to develop a consistent user experience across all platforms. If you&#8217;re familiar with the doctypes of HTML 4 and XHTML 1, you are familiar with how complex they appear.</p>
<p><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br />
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;<br />
</code></p>
<p>Not the type of thing one would readily commit to memory at first glance. The HTML5 doctype is significantly shorter:</p>
<p><code>&lt;!DOCTYPE html&gt;<br />
</code></p>
<p>There &#8211; <a href="http://thereifixedit.failblog.org/">fixed it</a>.</p>
<p>With just a little experimentation, it was found that all browsers triggered standards mode with just the above minimal amount of code. So the HTML5 spec was written to codify what was already in existence, in the most compact and simplistic way that works. No long URL. No unmemorable string of voodoo or versioning cluster nonsense. Just the standards mode, please. That&#8217;s all we need &#8211; something simple and to the point.</p>
<p>The next thing you should know about is defining a character set for your document. This is a departure from the straightforwardness of our journey into HTML5 markup, but it is important for addressing a <a title="UTF-7: the case of the missing charset on Google Code" href="http://code.google.com/p/doctype/wiki/ArticleUtf7">security concern</a> where browsers attempt to guess character encodings that could conceal malicious scripts, so let&#8217;s get off on the right foot shall we? First, the old way:</p>
<p><code>&lt;meta http-equiv= "Content-Type" content="text/html; charset=UTF-8"&gt;<br />
</code></p>
<p>Again, not the most memorable code. But then, that&#8217;s why I like HTML5: It fixes things. This is much better:</p>
<p><code>&lt;meta charset="utf-8"&gt;<br />
</code></p>
<p>I should also point out something important here. In HTML5, you don&#8217;t need to place quotation marks around attribute values if there are no spaces. Spaces separate multiple values, and you need those quotes to herd them together and distinguish them from standalone attributes (which we&#8217;ll get into later). So, this would also be perfectly valid:</p>
<p><code>&lt;meta charset=utf-8&gt;<br />
</code></p>
<p>If you&#8217;re compressing a document for speedy delivery over slow networks, such as mobile contexts, then here&#8217;s a place to save a few bytes. But in general, it&#8217;s my personal preference to quote my attribute values for legibility&#8217;s sake.</p>
<p>Another thing you might notice is that this standalone element is not self-closing in the XML sense. You could write it that way, as in:</p>
<p><code>&lt;meta charset="utf-8" /&gt;<br />
</code></p>
<p>That&#8217;s with the trailing slash before the end closing angle bracket, in case you missed it. This would be the way it would be done were our document conforming to XHTML rules. XHTML5 is the XML-conformant variant of HTML5 and is developed as an option to the HTML5 specification. But it is not necessary, unless you really need XML parsing to be enabled. And the good news is, HTML5 allows for SVG and MathML embedding without having to switch to XHTML mode, so for most contexts even at the scientific level, we won&#8217;t need the X tacked on to the front of our HTML5. But please, don&#8217;t let that stop you from self-closing those tags. I myself only recently got out of the habit, after writing HTML5 for the past 10 months or so. It&#8217;s perfectly valid either way.</p>
<p>The rest of your basic HTML5 document at this point will look very familiar, with just a few things to point out. The most notable difference will be the opening HTML tag. Usually we&#8217;d just open up our markup tree with this:</p>
<p><code>&lt;html&gt;<br />
</code></p>
<p>However, if we were pulling out all the XML stops and such, we would be defining a namespace and a language, as so:</p>
<p><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"&gt;<br />
</code></p>
<p>In HTML5, it is certainly not necessary to define a namespace (the xmlns part) because that much is assumed. That leaves us with the language declaration, in the form of the lang attribute. Lang attributes are specified according to <a title="IETF BCP 47: Tags for Identifying Languages" href="http://www.ietf.org/rfc/bcp/bcp47.txt">IETF BCP47</a>, and there&#8217;s a <a title="MSDN: Language Codes" href="http://msdn.microsoft.com/en-us/library/ms533052(VS.85).aspx">practical list of these codes</a> that may be used on MSDN. A lang attribute is used by search engines to understand the content meaning better and categorize the results. It is used by speech synthesizers to produce the correct pronunciation of words with similar spellings across languages. It is used by browsers for producing the correct hyphenation, spelling correction, and so on, even across regional dialects. A lang attribute specifies the language of the contents of the given element, which means you may specify several languages on a given document.</p>
<p>Do use the lang attribute. Even better &#8211; use it regionally. I would specify lang=&#8221;en-us&#8221; (English &#8211; U.S.) for most of my web work, but on occasion I&#8217;ll dip into Traditional Chinese for my language studies, with specific vocabulary rules for Taiwan, in which case I&#8217;d use lang=&#8221;zh-tw&#8221; (Chinese, or &#8220;zhongwen&#8221; &#8211; Taiwan).</p>
<p>I&#8217;m fascinated by language processing and character sets in computing, so forgive my overly-thorough description of the situation back there. The point is, in HTML5, we can shorten this information on the opening HTML element to this by removing the namespace and the xml:lang attributes, and including the addition of my regional preference:</p>
<p><code>&lt;html lang="en-us"&gt;<br />
</code></p>
<p>There, that&#8217;s a <em>gooood</em> HTML element. For other elements in your document, such as perhaps LI or P, you might specify additional languages as needed.</p>
<p>Bruce Lawson has a <a title="Bruce Lawson’s  personal site : A Minimal HTML5 Document" href="http://www.brucelawson.co.uk/2010/a-minimal-html5-document/">nice, clear writeup</a> of what he considers to be the minimal HTML5 document framework. I agree with this markup template, with my own minor stylistic modifications presented below:</p>
<p><code>&lt;!DOCTYPE html&gt;<br />
&lt;html lang="en-us"&gt;<br />
&lt;head&gt;<br />
&nbsp;&nbsp;&lt;meta charset="utf-8"&gt;<br />
&nbsp;&nbsp;&lt;title&gt;My Page Title&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&nbsp;&nbsp;&lt;p&gt;My awesome web page.&lt;/p&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
</code></p>
<p>The rest is pretty straightforward, right? We have the overall wrapping HTML element, a HEAD, a BODY, our charset definition, our lang attribute set to Amurikun, well-formed tag organization, a title attribute, and some content. That&#8217;s it &#8211; not too different from our past experiences with HTML4 and XHTML, but arguably much simpler. You now can fill in the rest of your markup as needed as if it were HTML 4.01, and it&#8217;ll work in all modern browsers. That&#8217;s right, it&#8217;s OK to get started with this much right away. But if we stopped there, that would be missing the point of the new semantic conveniences of HTML5! So in the next post we will explore those constructs in a little more detail and talk about how these new constructs will save you time and make more sense for web development in the long run.</p>

]]></content:encoded>
			<wfw:commentRss>http://www.sanbeiji.com/archives/1214/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cheatsheet from today&#8217;s Open Web Camp &#8220;Refactoring for Mobile&#8221; talk</title>
		<link>http://www.sanbeiji.com/archives/1175</link>
		<comments>http://www.sanbeiji.com/archives/1175#comments</comments>
		<pubDate>Sun, 18 Jul 2010 05:56:09 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://www.sanbeiji.com/?p=1175</guid>
		<description><![CDATA[For the Open Web Camp attendees, here&#8217;s my cheatsheet from the Refactoring for Mobile talk I gave today at Stanford: Get it as a CSS file and view it in your favorite code editor: walkthrough.css Or preview here: /* The &#8230; <a href="http://www.sanbeiji.com/archives/1175">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_brick-red" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.sanbeiji.com%252Farchives%252F1175%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2Fa7Z6gx%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Cheatsheet%20from%20today%27s%20Open%20Web%20Camp%20%5C%22Refactoring%20for%20Mobile%5C%22%20talk%22%20%7D);"></div>
<p>For the Open Web Camp attendees, here&#8217;s my cheatsheet from the Refactoring for Mobile talk I gave today at Stanford:</p>
<p>Get it as a CSS file and view it in your <a href="http://macromates.com/">favorite</a> <a href="http://www.vim.org/">code</a> <a href="http://www.adobe.com/products/dreamweaver/">editor</a>: </p>
<p><a href='http://www.sanbeiji.com/wp-content/uploads/2010/07/walkthrough.css' style="font-weight:bold;">walkthrough.css</a></p>
<p>Or preview here:</p>
<p><code><br />
/*<br />
The first thing we need is a media query and to add<br />
&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,<br />
	minimum-scale=1.0, maximum-scale=1.0&quot;&gt;<br />
to the head:<br />
*/<br />
@media only screen and (max-device-width:480px) {<br />
/*<br />
For starters, note the two divs #wrapper and #contents.<br />
Let's use those to create our structural layout and<br />
fold back in some of those design elements.<br />
*/<br />
	#wrapper {<br />
		background:url(img/back2.png) no-repeat center top;<br />
		margin-top:-1em;<br />
	}<br />
	#contents {<br />
		text-align:left;<br />
		width:95%;<br />
		margin:0 auto;<br />
	}<br />
/*<br />
Now, let's style the main navigation buttons. First, we<br />
will use inline-block to give block-like behavior to the<br />
buttons but retain width based on the content. Then we set<br />
the color, font size, and floating, and add a bit of box<br />
shadow.<br />
*/<br />
	.menu a {<br />
		display:inline-block;<br />
		background-color:#000;<br />
		float:left;<br />
		font-size:14px;<br />
		padding:1em 0.95em;<br />
		border-left:1px solid #888;<br />
		-webkit-box-shadow:0px 1px 5px #222;<br />
	}<br />
/*<br />
We can now use border-radius to style the left and right<br />
buttons instead of image files:<br />
*/<br />
	.first_menu a {<br />
		border-bottom-left-radius:6px;<br />
		border-left:none;<br />
		margin-left:2px;<br />
	}<br />
	.menu li:last-child a {<br />
		border-bottom-right-radius:6px;<br />
	}<br />
/*<br />
What if we flip to Landscape? There's a media query for<br />
that:<br />
*/<br />
	@media screen and (orientation:landscape) {<br />
		.first_menu a {<br />
			margin-left:78px;<br />
		}<br />
	}<br />
/*<br />
Now we can style the body content. #middle-contents is<br />
the main containing block. We can use the background image<br />
from the main stylesheet, but alternately we can use rgba<br />
backgrounds to get finer control. Add border radius and box<br />
shadow for depth.<br />
*/<br />
	#middle-contents {<br />
/*		background:url(img/side.png) repeat-y;*/<br />
		background-color:rgba(0,0,0,0.3);<br />
		padding:1em;<br />
		border-radius:10px;<br />
		-webkit-box-shadow:0px 1px 6px #000;<br />
		box-shadow:0px 1px 6px #000;<br />
		font-size:1.2em;<br />
		margin-bottom:1em;<br />
	}<br />
/*<br />
Let's style the banner text and have some fun with it using<br />
web fonts. Here's a font we'll pull in, using TTF and SVG formats.<br />
Sadly, the vendors have many opinions on the solution, but<br />
FontSquirrel can help sort it out.<br />
*/<br />
	@font-face {<br />
		font-family:'Lobster';<br />
		src: url('Lobster_1.3-webfont.ttf') format('truetype'),<br />
		url('Lobster_1.3-webfont.svg#webfontcOtP3oQb') format('svg');<br />
	}<br />
	#logo a {<br />
		display:block;<br />
		text-align:center;<br />
		padding-top:12px;<br />
		font-family:Lobster, sans-serif;<br />
		font-size:2.7em;<br />
		text-shadow:0px 2px 4px #000;<br />
	}<br />
	#logo h1 {<br />
		font-family:Lobster, sans-serif;<br />
		text-align:center;<br />
		font-size:1.5em;<br />
	}<br />
/*<br />
The float is creating a spacing issue. We can fix that<br />
with a clear:<br />
*/<br />
	#header { clear:both; }<br />
/*<br />
We are getting close. Now on to the bottom of the page.<br />
The #comments section is too wide. We need to reset it:<br />
*/<br />
	#comments {<br />
		width:100%;<br />
	}<br />
	#comments textarea, #comments input {<br />
		width:93%;<br />
		margin-bottom:0.5em;<br />
		padding:0.5em;<br />
		font-size:1.2em;<br />
		border:1px solid #000;<br />
		border-radius:6px;<br />
	}<br />
/*<br />
That input button could be nicer:<br />
*/<br />
	#comments input.button {<br />
		display:block;<br />
		width:80%;<br />
		margin:0 auto;<br />
		height:2.5em;<br />
		padding:0.5em;<br />
	}<br />
/*<br />
Now we have something that looks like it was meant for a<br />
mobile device. Let's wrap this up by making the final<br />
links look like tap-friendly buttons:<br />
*/<br />
	#right-col a {<br />
		display:block;<br />
		padding:0.5em;<br />
		font-size:1.3em;<br />
		font-weight:bold;<br />
		text-align:center;<br />
		background-image: -webkit-gradient(linear, left top, left bottom,<br />
			from(#666666), to(#666666), color-stop(.5,#333));<br />
		border:1px solid #000;<br />
		border-radius:20px;<br />
		margin-bottom:0.4em;<br />
	}<br />
/*<br />
Maybe those final link items were over the top.<br />
Let's restore them to inline links:<br />
*/<br />
	#copyrights a {<br />
		display:inline;<br />
		margin:0;<br />
		padding:0;<br />
		font-size:small;<br />
		border:none;<br />
		background-image:none;<br />
	}<br />
}<br />
/*<br />
Now add some HTML5: Add placeholder="I think..." to the textarea in<br />
comments.php, line 191.<br />
Add input types to email and url fields.<br />
Finish with atouch icon: &lt;link rel=&quot;apple-touch-icon&quot; href=&quot;piano.png&quot;/&gt;<br />
(Note to attendees: I forgot to add the piano.png file to my project files.<br />
But this works otherwise!)<br />
*/<br />
</code></p>

]]></content:encoded>
			<wfw:commentRss>http://www.sanbeiji.com/archives/1175/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Waxing Firefox, Waning IE</title>
		<link>http://www.sanbeiji.com/archives/978</link>
		<comments>http://www.sanbeiji.com/archives/978#comments</comments>
		<pubDate>Sat, 03 Jan 2009 03:16:45 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[opera]]></category>
		<category><![CDATA[Web Standards]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://www.sanbeiji.com/?p=978</guid>
		<description><![CDATA[IE continues it&#8217;s downward spiral as the browser dips below 69% at the expense of Firefox and the WebKit-powered duo of Apple Safari and Google Chrome. The breakdown as paraphrased by TG Daily: Net Applications released updated global browser market &#8230; <a href="http://www.sanbeiji.com/archives/978">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_brick-red" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.sanbeiji.com%252Farchives%252F978%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Waxing%20Firefox%2C%20Waning%20IE%22%20%7D);"></div>
<p>IE continues it&#8217;s downward spiral as the browser <a href="http://www.tgdaily.com/html_tmp/content-view-40800-113.html" title >dips below 69%</a> at the expense of Firefox and the WebKit-powered duo of Apple Safari and Google Chrome. The breakdown as paraphrased by TG Daily:</p>
<blockquote><p>Net Applications released updated <a href="http://marketshare.hitslink.com/report.aspx?qprid=0" title="Market share for browsers, operating systems and search engines">global browser market share</a> numbers today, indicating that IE is losing users at an accelerated pace. The browser’s share dropped from 69.77% in November to 68.15% in December. Most rivals were able to pick up a portion of what IE surrendered. Firefox gained more than half a point and ended up at 21.34%, Safari approaches the next big hurdle with 7.93% and Chrome came in at 1.04%, the first time Google was able to cross the 1% mark. Opera remained stable 0.71%, but it is clear that the Norwegian browser cannot attract any users IE loses.</p></blockquote>
<p>This is no surprise. Taking into account the seasonal fluctuation towards home users in December which point to higher &#8220;non-corporate&#8221; platforms and browsers, this is still a landmark statistic and shows that if the gradual decline continues, 60% and 50% are not that far off in the future. As the trend for Firefox and WebKit to rise at the expense of IE has been continuing for some time now. What surprises me are a couple of things though, specifically:</p>
<ol>
<li>The rate at which IE is losing overall market share: While I predicted a decline in market share over the long term, I didn&#8217;t think I&#8217;d ever see it declining at the rate it is currently declining on a month to month average. It just <em>seems</em> steep to me.</li>
<li>Opera adoption: I thought that more people would pick up Opera &#8211; at least I thought they&#8217;d have 2 or 3 percent by now. They are by far the most deployed browser on the mobile web, but nobody knows it really because they could care less what browser is being activated from their baked-up phone UI, and it&#8217;s unlikely that they use it much (which is the fault of the phone vendors &#8211; Opera Mobile by itself is great.) I like Opera. It&#8217;s not my default browsaer, but I find myself using it from time to time for certain things. Certainly for <a href="http://twitter.com/sanbeiji/status/1091780846" title="Twitter / Joe Lewis: finds it wrong that most o ...">print</a> and <a href="http://www.opera.com/browser/tutorials/operashow/" title="Opera: Tutorial - Opera Show">presentations</a>, and also it&#8217;s handy mobile web dev in Small Screen mode.</li>
</ol>
<p>I wonder how much of those Safari numbers are being driven from iPhone and iPod Touch users? What is also interesting in these metrics is the inclusion of Google&#8217;s <a href="http://www.google.com/chrome" title="Google Chrome - Download a new browser">Chrome</a> browser, which again is based on the WebKit core that Safari is founded upon. Chrome broke 1%, and at the same time they have begun recommending against IE and in favor of Firefox and Chrome for Google Gmail users. This is an interesting coup attempt to grab their Gmail base still floundering on IE6, and it is even more noteworthy that IE7 was not mentioned as an alternative. I am betting Chrome will be a major contender a year from now, and the overall WebKit market share might even approach Firefox&#8217;s levels. What is probably safe to predict is that IE will continue to lose out to Firefox and WebKit-based browsers and I would not be surprised at this point if the rate of increase in adoption of alternative browsers began to accelerate in 2009 towards these platforms.</p>
<p>It is nice to see strong lines of diversity returning to the browser market. The benefit will be for better browsers and stronger support overall for web standards.</p>

]]></content:encoded>
			<wfw:commentRss>http://www.sanbeiji.com/archives/978/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The madness of screens vs. browsers on the mobile web</title>
		<link>http://www.sanbeiji.com/archives/969</link>
		<comments>http://www.sanbeiji.com/archives/969#comments</comments>
		<pubDate>Mon, 29 Dec 2008 06:10:41 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[Safari]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://www.sanbeiji.com/?p=969</guid>
		<description><![CDATA[This evening as I was doing some research on mobile web development, I got myself on a tear about the wild differences we face as web developers regarding screen sizes and default browser installations, and came up with this: Make &#8230; <a href="http://www.sanbeiji.com/archives/969">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_brick-red" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.sanbeiji.com%252Farchives%252F969%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22The%20madness%20of%20screens%20vs.%20browsers%20on%20the%20mobile%20web%22%20%7D);"></div>
<p>This evening as I was doing some research on mobile web development, I got myself on a tear about the wild differences we face as web developers regarding screen sizes and default browser installations, and came up with this:</p>
<table summary="Table listing make, model, resolution, and default browser engine for mobile phone devices.">
<tr>
<th>Make</th>
<th>Model</th>
<th>Resolution</th>
<th>Default Browser Engine*</th>
</tr>
<tr>
<td>Amazon</td>
<td>Kindle</td>
<td>600 x 800</td>
<td>NetFront</td>
</tr>
<tr>
<td>Apple</td>
<td>iPhone</td>
<td>480 x 320</td>
<td>WebKit</td>
</tr>
<tr>
<td>Apple</td>
<td>iPod Touch</td>
<td>480 x 320</td>
<td>WebKit</td>
</tr>
<tr>
<td>BenQ</td>
<td>M315</td>
<td>128 x 128</td>
<td>Opera</td>
</tr>
<tr>
<td>HTC</td>
<td>G1</td>
<td>320 x 480</td>
<td>WebKit</td>
</tr>
<tr>
<td>Kyocera</td>
<td>Mako S4000</td>
<td>128 x 160</td>
<td>Openwave</td>
</tr>
<tr>
<td>Motorola</td>
<td>Hint QA30</td>
<td>320 x 240</td>
<td>Openwave</td>
</tr>
<tr>
<td>Motorola</td>
<td>Krave ZN4</td>
<td>240 x 400</td>
<td>Openwave</td>
</tr>
<tr>
<td>Motorola</td>
<td>KRZR K1</td>
<td>176 x 220</td>
<td>Opera</td>
</tr>
<tr>
<td>Motorola</td>
<td>RAZR V3</td>
<td>176 x 220</td>
<td>Opera</td>
</tr>
<tr>
<td>Motorola</td>
<td>ROKR E2</td>
<td>240 x 320</td>
<td>Opera</td>
</tr>
<tr>
<td>Motorola</td>
<td>SLVR L7</td>
<td>176 x 220</td>
<td>Opera</td>
</tr>
<tr>
<td>Motorola</td>
<td>V980</td>
<td>176 x 220</td>
<td>Opera</td>
</tr>
<tr>
<td>Motorola</td>
<td>VE240</td>
<td>128 x 128</td>
<td>Openwave</td>
</tr>
<tr>
<td>Motorola</td>
<td>ZINE ZN5</td>
<td>240 x 320</td>
<td>WebKit</td>
</tr>
<tr>
<td>Nokia</td>
<td>6300</td>
<td>240 x 320</td>
<td>Opera</td>
</tr>
<tr>
<td>Nokia</td>
<td>2605 Mirage</td>
<td>128 x 160</td>
<td>Openwave</td>
</tr>
<tr>
<td>Nokia</td>
<td>N81</td>
<td>240 x 320</td>
<td>WebKit</td>
</tr>
<tr>
<td>Nokia</td>
<td>N810</td>
<td>800 x 480</td>
<td>Gecko</td>
</tr>
<tr>
<td>Nokia</td>
<td>N82</td>
<td>240 x 320</td>
<td>WebKit</td>
</tr>
<tr>
<td>Nokia</td>
<td>N95</td>
<td>240 x 320</td>
<td>WebKit</td>
</tr>
<tr>
<td>Nokia</td>
<td>N96</td>
<td>240 x 320</td>
<td>WebKit</td>
</tr>
<tr>
<td>Palm</td>
<td>Centro</td>
<td>320 x 320</td>
<td>NetFront</td>
</tr>
<tr>
<td>Palm</td>
<td>Treo 680</td>
<td>320 x 320</td>
<td>NetFront</td>
</tr>
<tr>
<td>Palm</td>
<td>Treo 750</td>
<td>240 x 240</td>
<td>Internet Explorer</td>
</tr>
<tr>
<td>Palm</td>
<td>Treo 755p</td>
<td>320 x 320</td>
<td>NetFront</td>
</tr>
<tr>
<td>Palm</td>
<td>Treo 800w</td>
<td>320 x 320</td>
<td>Internet Explorer</td>
</tr>
<tr>
<td>Palm</td>
<td>Treo Pro</td>
<td>320 x 320</td>
<td>Internet Explorer</td>
</tr>
<tr>
<td>RIM</td>
<td>Blackberry Bold</td>
<td>480 x 360</td>
<td>Blackberry Browser</td>
</tr>
<tr>
<td>RIM</td>
<td>Blackberry Pearl</td>
<td>240 x 320 </td>
<td>Blackberry Browser</td>
</tr>
<tr>
<td>RIM</td>
<td>Blackberry Storm</td>
<td>480 x 360</td>
<td>Blackberry Browser</td>
</tr>
<tr>
<td>Samsung</td>
<td>Behold T919</td>
<td>240 x 400</td>
<td>NetFront</td>
</tr>
<tr>
<td>Samsung</td>
<td>BlackJack SGH-i607</td>
<td>240 x 320</td>
<td>Internet Explorer</td>
</tr>
<tr>
<td>Samsung</td>
<td>Epix i907</td>
<td>320 x 320</td>
<td>Internet Explorer</td>
</tr>
<tr>
<td>Samsung</td>
<td>Eternity SGH-A867</td>
<td>240 x 400</td>
<td>Openwave</td>
</tr>
<tr>
<td>Samsung</td>
<td>Highnote M630</td>
<td>176 x 220</td>
<td>Polaris</td>
</tr>
<tr>
<td>Samsung</td>
<td>Omina i910</td>
<td>240 x 400</td>
<td>Internet Explorer &amp; Opera</td>
</tr>
<tr>
<td>Samsung</td>
<td>Rant M540</td>
<td>176 x 220</td>
<td>Polaris</td>
</tr>
<tr>
<td>Samsung</td>
<td>Rugby A837</td>
<td>176 x 220</td>
<td>NetFront</td>
</tr>
<tr>
<td>Samsung</td>
<td>Saga i770</td>
<td>320 x 320</td>
<td>Internet Explorer &amp; Opera</td>
</tr>
<tr>
<td>Samsung</td>
<td>SPH-Z400</td>
<td>176 x 220</td>
<td>Obigo</td>
</tr>
<tr>
<td>Siemens</td>
<td>SX66</td>
<td>240 x 320</td>
<td>Internet Explorer</td>
</tr>
<tr>
<td>Sonim</td>
<td>XP3</td>
<td>128 x 160</td>
<td>Opera</td>
</tr>
<tr>
<td>Sony Ericsson</td>
<td>C702a</td>
<td>240 x 320</td>
<td>NetFront</td>
</tr>
<tr>
<td>Sony Ericsson</td>
<td>C905a</td>
<td>240 x 320</td>
<td>NetFront</td>
</tr>
<tr>
<td>Sony Ericsson</td>
<td>TM506</td>
<td>240 x 320</td>
<td>NetFront</td>
</tr>
<tr>
<td>Sony Ericsson</td>
<td>W595a</td>
<td>240 x 320</td>
<td>NetFront</td>
</tr>
<tr>
<td>Sony Ericsson</td>
<td>W760</td>
<td>240 x 320</td>
<td>NetFront</td>
</tr>
<tr>
<td>Sony Ericsson</td>
<td>X1</td>
<td>800 X 480</td>
<td>Internet Explorer &amp; Opera</td>
</tr>
</table>
<p><em>*Some service providers will opt to use a different browser than the ones listed here.</em></p>
<p>It is interesting to note the diversity on these fronts. Screen sizes are all over the map, and the browsers here are not the usual suspects we see on the desktop. As for browsers, while it is certainly possible on many of these platforms to install a different browser (Opera being the usual choice), most users don&#8217;t bother. Regardless, Opera is the dominant player in this space, with significant marketshare owned by all the other actors on the mobile stage. As I research this topic, the WebKit engine proves to be the vast trendsetter and it is interesting to see how many platforms besides the iPhone are picking this one up. And trends show that this landscape is evolving rapidly as mobile capabilities increase and users begin surfing the web on their mobile devices with greater and greater frequency. <a href="http://www.abiresearch.com/press/1299-As+Mobile+Web+Usage+Explodes%2C+Full-Featured+Browsers+on+Smartphones+See+Strongest+Growth" title="As Mobile Web Usage Explodes, Full-Featured Browsers on Smartphones See Strongest Growth | Press Release | ABI Research">ABI Research sees</a> web browser installations on smartphones expanding from 130 million in 2008 to 530 million by 2013. The mobile web is a vastly unexplored frontier in web design and we should start seeing more and more attention getting paid to this aspect of the online world.</p>
<p><em>Update:</em> Amazon Kindle&#8217;s Basic Web is based on NetFront &#8211; table updated to reflect this.</p>

]]></content:encoded>
			<wfw:commentRss>http://www.sanbeiji.com/archives/969/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The woes of CSS color in print typography</title>
		<link>http://www.sanbeiji.com/archives/953</link>
		<comments>http://www.sanbeiji.com/archives/953#comments</comments>
		<pubDate>Mon, 08 Dec 2008 04:57:21 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[typography]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://www.sanbeiji.com/?p=953</guid>
		<description><![CDATA[As I was working through some documentation on styling CSS for print recently, I came across an oddity. Colors that I was specifying in my print styles were not getting represented properly at print time. Specify a nice shade of &#8230; <a href="http://www.sanbeiji.com/archives/953">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_brick-red" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.sanbeiji.com%252Farchives%252F953%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22The%20woes%20of%20CSS%20color%20in%20print%20typography%22%20%7D);"></div>
<p><a href="http://www.flickr.com/photos/sanbeiji/406392716/" title="Smoking Room/Prayer Room by sanbeiji, on Flickr"><img src="http://farm1.static.flickr.com/186/406392716_a2e4e12ccf_m.jpg" alt="Smoking Room/Prayer Room" class="right" /></a></p>
<p>As I was working through some documentation on styling CSS for print recently, I came across an oddity. Colors that I was specifying in my print styles were not getting represented properly at print time. Specify a nice shade of gray for some text? Maybe want to ghost print something very lightly on the printed page. No &#8211; not in Firefox. In fact, any shade of gray comes out as black in Gecko browsers. This behavior is only slightly more intelligent in Safari and IE7, but in all cases the user agent makes an assumption about what color of text constitutes being &#8220;too light&#8221; and then defaults to a darker shade of pale that is handled inconsistently across the various browsers. Printing font colors appears to be a messy situation.</p>
<p>Now the reason why the browser vendors have made this assumption is clear: Printing light text on what is almost always white paper is largely unreadable. Furthermore, printing in pure black, devoid of any complex color mixing, can make printing much faster, because the printer doesn&#8217;t have to mix in any red, green, or blue ink and can focus on getting the task done. But what is maddening to the designer trying to achieve accurate color representation in print from their web pages is that all of the major browsers assume that they are smarter than the designer, and recolor the text based on their own inconsistent algorithms. Actually, that may be assuming a bit much on the part of the browsers &#8211; sometimes the results defy logic. </p>
<p>To investigate further, I created a <a href="http://sanbeiji.com/tests/textcolor.php" title="Print CSS Text Color Test">testing page</a>. This page runs through some of the various color gamuts and creates a list entry for a number of color variations. The results are surprising&#8230; Here are some findings:</p>
<ul>
<li>
<p>Safari 3: Between rgb(0,0,0) and rgb(107,107,107), things appear fine. But then there is a breakdown between rgb(108,108,108) and rgb(127,127,127) where the text will randomly jump to a light gray &#8211; equivalent of rgb(199,199,199). For lack of a better term, I call this area &#8220;The Dead Zone,&#8221; and we will see it again soon. At rgb(128,128,128), the text color then jumps to black and as you ascend the values towards an expected white color, Safari yields a progressive amount of additional lightness to the text until it finally winds up at around rgb(171,171,171) where it should be 255 for all values.</p>
<p>The Dead Zone also occurs in the red, green, and blue colorspaces. If you fix red at 127, about halfway between the minimum value of 0 and the maximum value of 255, we get a dead zone between rgb(127,100,100) and rgb(127,127,127). Same ratios happen starting at rgb(100,127,100), and at rgb(100,100,127).</p>
<p>Finally, Safari renders rgb(0,255,255), rgb(255,0,255), and rgb(255,255,0) inconsistently from their adjacent color values.</p>
</li>
<li>
<p>Gecko browsers such as Firefox, Camino, and Flock print the entire gray space in black. (Exception: Firefox 3 will actually print the color exactly right &#8211; see below.) You cannot specify a light gray such as rgb(127,127,127) or anything else. It will always default to pure black whether you like it or not. If you fix a color bucket at 0, you will get semi-accurate color for the rest of the gamut, but the other color combinations will trend towards black text the lighter it gets.</p>
</li>
<li>
<p>In Opera 9, gray shades render accurately up until rgb(185,185,185), and then higher values default to black. In the points tested, the same conversion to black happens after values higher than rgb(127,211,211), rgb(255,156,156), rgb(87,255,255), rgb(209,209,0), rgb(193,193,127), and rgb(177,177,255).</p>
</li>
<li>
<p>IE7 never gets any lighter than rgb(108,104,102) for grayscale, and the rest of the color spaces don&#8217;t seem to allow anything lighter than a midrange hue equivalent to around 110 for any given value.</p>
</li>
<li>
<p>One last thing about Gecko browsers: The marker (the little bullet to the left of each list item) will display the correct color value in print, even though the text itself won&#8217;t match! Underlines/Overlines/strikethrough will match whatever color the text is though. So at least here you can see what the color was <em>supposed</em> to be&#8230;</p>
</li>
<li>
<p>The exception as mentioned above is Firefox 3. Firefox 3 has been tested to print the colors exactly as you see them on screen, and is the only browser thus far that works this way in a predictable manner.</p>
</li>
</ul>
<p>The conclusion I draw from all of this is that color in CSS print typography is woefully inconsistent, and I do recommend defaulting to black text in most cases simply because it is so problematic to predict what color you will actually wind up with in print. If you need color, go with a darker shade and <a href="http://sanbeiji.com/tests/textcolor.php" title="Print CSS Text Color Test">test your print output</a> in the four major modern browsers (IE, Safari, Firefox, Opera) to see what you can get away with.</p>
<p>Please feel free to <a href="http://sanbeiji.com/tests/textcolor.php" title="Print CSS Text Color Test">try the test suite for yourself</a> and let me know your findings in the comments or via a pingback. </p>

]]></content:encoded>
			<wfw:commentRss>http://www.sanbeiji.com/archives/953/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The non-importance of !important</title>
		<link>http://www.sanbeiji.com/archives/883</link>
		<comments>http://www.sanbeiji.com/archives/883#comments</comments>
		<pubDate>Tue, 05 Aug 2008 19:26:43 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[cascade]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://www.sanbeiji.com/?p=883</guid>
		<description><![CDATA[Molly Holzschlag raised a good issue via Twitter yesterday regarding the !important rules in CSS, reprinted here in more or less the order in which her tweets appeared thus far: TwitterPoll: What does this mean to you? != TwitterPoll follow-up. &#8230; <a href="http://www.sanbeiji.com/archives/883">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_brick-red" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.sanbeiji.com%252Farchives%252F883%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22The%20non-importance%20of%20%21important%22%20%7D);"></div>
<p><cite class="vcard"><abbr class="fn" title="Molly Holzschlag"><a class="nickname" href="http://www.molly.com/">Molly Holzschlag</a></abbr></cite> raised a good issue <a href="http://twitter.com/mollydotcom">via Twitter</a> yesterday regarding the <code>!important</code> rules in CSS, reprinted here in more or less the order in which her tweets appeared thus far:</p>
<blockquote><p><a href="http://twitter.com/mollydotcom/statuses/877745734">TwitterPoll</a>: What does this mean to you? !=</p></blockquote>
<blockquote><p>TwitterPoll <a href="http://twitter.com/mollydotcom/statuses/877754367">follow-up</a>. What does this mean to you? !=good</p></blockquote>
<blockquote><p>TwitterPoll: Let&#8217;s <a href="http://twitter.com/mollydotcom/statuses/877805427">remove the equal sign</a>. What does this mean to you !good</p></blockquote>
<blockquote><p>yes, yes, I&#8217;m asking ultimately how the fuck !important means BANG IMPORTANT when realistically <a href="http://twitter.com/mollydotcom/statuses/877820869">it should mean not important</a>.</p></blockquote>
<blockquote><p>re: !important in CSS? <a href="http://twitter.com/mollydotcom/statuses/877975257">Kill it</a>. Specificity to the rescue.</p></blockquote>
<blockquote><p><a href="http://twitter.com/mollydotcom/statuses/878004442">Say it</a> ten times fastL Specificity, specificity, specificity. Forget !important. Write specific selectors sez me. And night night!</p></blockquote>
<p>I love Twitter. When it is up and running that is&#8230; <img src='http://www.sanbeiji.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  Such a lively place for discussion.</p>
<p><a href="http://www.flickr.com/photos/sanbeiji/2688126716/" title="Random photo from my recent Taiwan trip, just for color."><img src="http://farm4.static.flickr.com/3125/2688126716_148898fd31_m.jpg" class="right" alt="Random photo of Taroko Gorge from my recent Taiwan trip, just for color." /></a></p>
<p>Molly makes an excellent point here. My little position with the <code>!important</code> rule is that I always thought this to be somewhat of a funny-looking construct. It is just as Molly points out &#8211; the exclamation point preceding the word &#8216;important&#8217; is odd, kind of stuck on there, and is especially confusing to those of us coming from that programming background where the ! means &#8216;not&#8217; &#8211; as in != reading &#8216;not equal&#8217; and that sort of thing.</p>
<p>The construct itself is generally frowned upon in production-level CSS code. The specificity of the <code>!important</code> rule overrides anything with normal inheritance values, and if your code is littered with it then you really need to go back and look at what your rules are doing with regards to the cascade. A good production stylesheet should be free of any <code>!important</code> rules.</p>
<p>I take from Molly&#8217;s tweets that she argues in favor of abolishing the <code>!important</code> construct and that people should use the cascade properly. While I understand this position and agree with it on a philosophical level, I think somehow this functionality should be retained. My proposal is as follows:</p>
<ol>
<li>Change <code>!important</code> to just <code>important</code>, doing away with the confusing exclamation point and instantly making CSS more legible</li>
<li>Make some declaration that user agents should ignore the exclamation point and really just pay attention to the word &#8220;important,&#8221; for the sake of legacy support. <em>Yeah more detail is needed here, but you get it.</em></li>
<li>Make validation issue an explicit warning stating that <code>important</code> should only be used for debugging purposes.</li>
</ol>
<p>How this would look in the wild:</p>
<p><code>#hyrule {<br />
&nbsp;&nbsp;color:blue important;<br />
}</code></p>
<p>Not a big change really, but it gets rid of the somewhat confusing exclamation point, gets us more towards the ideal which is reduced abuse of the rule in question, and promotes better use of the cascade.</p>
<p>Yes that photo is completely random given the context of this discussion, but I thought it was pretty and it reminds me that I need to do a follow-up on my recent Taiwan vacation&#8230; <img src='http://www.sanbeiji.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

]]></content:encoded>
			<wfw:commentRss>http://www.sanbeiji.com/archives/883/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced

Served from: www.sanbeiji.com @ 2012-02-11 05:11:49 -->
