<?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>Learning the World &#187; code</title>
	<atom:link href="http://learningtheworld.eu/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://learningtheworld.eu</link>
	<description></description>
	<lastBuildDate>Tue, 06 Nov 2012 00:17:33 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
	<item>
		<title>More CSS Drop Shadows For All Browsers</title>
		<link>http://learningtheworld.eu/2010/ms-box-shadow/</link>
		<comments>http://learningtheworld.eu/2010/ms-box-shadow/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 16:00:18 +0000</pubDate>
		<dc:creator><![CDATA[Martin Kliehm]]></dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[web standards]]></category>
		<category><![CDATA[blur]]></category>
		<category><![CDATA[box-shadow]]></category>
		<category><![CDATA[buttons]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[drop shadow]]></category>
		<category><![CDATA[eye-candy]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[ie6]]></category>
		<category><![CDATA[IE7]]></category>
		<category><![CDATA[ie8]]></category>
		<category><![CDATA[jumping-through-loops]]></category>
		<category><![CDATA[pseudo 3d]]></category>
		<category><![CDATA[shadow]]></category>
		<category><![CDATA[visual effects]]></category>

		<guid isPermaLink="false">http://learningtheworld.eu/?p=1021</guid>
		<description><![CDATA[Thanks to the unstoppable advancements of web standards aiding mankind to overcome the real burdens of the 21st century, adding drop shadows  to boxes became much easier in recent years! No more PNG background images! Leaving the question aside whether drop shadows are really progressive and appropriate for a flat medium (anybody remember the fad of “3D” bulging buttons in the 1990ies?), I&#160;was confronted with the challenge of adding box shadows in Internet Explorer for a client project.&#160;[&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Thanks to the unstoppable advancements of web standards aiding mankind to overcome the real burdens of the 21st century, adding <strong>drop shadows</strong> to boxes became much easier in recent years! No more PNG background images! Leaving the question aside whether drop shadows are really progressive and appropriate for a flat medium (anybody remember the fad of &ldquo;3D&rdquo; <a href="http://www.handson.nu/">bulging buttons</a> in the 1990ies?), I&nbsp;was confronted with the challenge of adding box shadows in Internet Explorer for a client project.</p>

<p><strong>Pro tip:</strong> communicate to the client that shadows are a <strong>bonus feature</strong>. Your designers may disagree, but the site will not suffer considerably when special effects like box shadows, text shadows, or rounded corners are regarded as enhancements for decent browsers. However, your client&rsquo;s budget will suffer when they are determined to provide the same visual effects on outdated browsers such as <acronym title="Internet Explorer 6">IE6</acronym>. That said, here is the well-known method in <acronym title="Cascading Style Sheets, 3rd Edition">CSS3</acronym>:</p>

<ol class="code" title="CSS">
<li><code><strong>.wrapper</strong> {</code></li>
<li class="indent"><code>background-color: #fff;</code></li>
<li class="indent"><code>border: 1px solid #d30d01;</code></li>
<li class="indent"><code><em>box-shadow:</em> 4px 4px 4px rgba(0, 0, 0, 0.2);</code></li>
<li class="indent"><code>float: left;</code></li>
<li class="indent"><code>height: 75px;</code></li>
<li class="indent"><code>margin: 15px;</code></li>
<li class="indent"><code>padding: 10px;</code></li>
<li class="indent"><code>width: 75px;</code></li>
<li class="indent"><code><em>-moz-box-shadow:</em> 4px 4px 4px rgba(0, 0, 0, 0.2);</code></li>
<li class="indent"><code><em>-o-box-shadow:</em> 4px 4px 4px rgba(0, 0, 0, 0.2);</code></li>
<li class="indent"><code><em>-webkit-box-shadow:</em> 4px 4px 4px rgba(0, 0, 0, 0.2);</code></li>
<li><code>}</code></li>
</ol>

<ol class="code" title="HTML code">
<li><code>&lt;div class=&quot;<em>wrapper</em>&quot;&gt;</code></li>
<li class="indent"><code>&lt;p&gt;CSS box-shadow&lt;/p&gt;</code></li>
<li><code>&lt;/div&gt;</code></li>
</ol>

<p>At the same time when we rolled out the website, Robert Nyman came to the conclusion that the proprietary Microsoft <code>filter</code> for <a href="http://robertnyman.com/2010/03/16/drop-shadow-with-css-for-all-web-browsers/"><code>Shadow</code> looks much prettier than <code>DropShadow</code></a>, so I forgot about blogging myself as his solution doesn&rsquo;t rely on unsemantic markup and is more elegant:</p>

<ol class="code" title="CSS">
<li><code><strong>.wrapper</strong> {</code></li>
<li class="indent">/* For IE 8 */</li>
<li class="indent"><code><em>-ms-filter: progid:DXImageTransform.Microsoft.Shadow</em>( Strength=5, Direction=135, Color='#999999' );</code></li>
<li class="indent">/* For IE 5.5 &#8211; 7 */</li>
<li class="indent"><code><em>filter: progid:DXImageTransform.Microsoft.Shadow</em>( Strength=5, Direction=135, Color='#999999' );</code></li>
<li><code>}</code></li>
</ol>

<p>Note that you get slightly better effects when you choose a dark gray instead of black as shadow color. If you can live with the rendering of the third box below, don&rsquo;t read any further. <img src="http://learningtheworld.eu/wp-includes/images/smilies/icon_wink.gif" alt=";)" class="wp-smiley" /> </p>

<p>However, applying the filter had the side effect that text inside the box wasn&rsquo;t anti-aliased in <acronym>IE</acronym> 6-8 anymore, and the shadow still didn&rsquo;t look decent enough. So we added an extra <code>span</code> and applied the <code>blur</code> filter on it.</p>

<p><img src="/wp-content/uploads/2010/08/screenshot-box-shadow.png" alt="Screenshot comparing the solutions for CSS drop shadows side by side" width="481" height="103" class="fullsize" /></p>

<p>That led to a more complex code as we needed an inner wrapper where the border and background is applied to, while the outer wrapper merely acted as a&nbsp;&hellip; wrapper, where the styles were reset to defaults. <acronym title="Hypertext Markup Language">HTML</acronym> first:</p>

<ol class="code" title="HTML code">
<li><code>&lt;div class=&quot;<em>wrapper ms-box-shadow</em>&quot;&gt;</code></li>
<li class="indent"><code><strong>&lt;div class=&quot;inner&quot;&gt;</strong></code></li>
<li class="indent double"><code>&lt;p&gt;<acronym>Internet Explorer</acronym> with blur filter&lt;/p&gt;</code></li>
<li class="indent"><code><strong>&lt;/div&gt;</strong></code></li>
<li class="indent"><code><strong>&lt;span class=&quot;shadow&quot;&gt;&lt;/span&gt;</strong></code></li>
<li><code>&lt;/div&gt;</code></li>
</ol>

<p>And here&rsquo;s the <acronym>CSS</acronym> that&rsquo;s added with Conditional Comments for <acronym>IE</acronym> 6-8 only (as <acronym>IE9</acronym> supports native <acronym>CSS</acronym> <code>box-shadow</code>, <a href="http://caniuse.com/#feat=css-boxshadow">more or less</a>). The shadow element is absolutely positioned, set behind the inner content and blown up to 100%. Not original, but it works:</p>

<ol class="code" title="CSS">
<li><code><strong>.wrapper, .inner</strong> {</code></li>
<li class="indent"><code>background-color: #fff;</code></li>
<li class="indent"><code>border: 1px solid #d30d01;</code></li>
<li class="indent"><code>height: 75px;</code></li>
<li class="indent"><code>padding: 10px;</code></li>
<li class="indent"><code><em>position: relative;</em></code></li>
<li class="indent"><code>width: 75px;</code></li>
<li><code>}</code></li>
<li><code><strong>.wrapper</strong> {</code></li>
<li class="indent"><code>float: left;</code></li>
<li class="indent"><code>margin: 15px;</code></li>
<li><code>}</code></li>
<li>/* reset wrapper styles to defaults; work-around for screwed box-model */</li>
<li><code><strong>.ms-box-shadow</strong> {</code></li>
<li class="indent"><code>background-color: transparent;</code></li>
<li class="indent"><code>border: 0 none;</code></li>
<li class="indent"><code>height: 95px;</code></li>
<li class="indent"><code>padding: 0;</code></li>
<li class="indent"><code>width: 95px;</code></li>
<li><code>}</code></li>
<li>/* Move the inner wrapper to the foreground */</li>
<li><code><strong>.inner</strong> {</code></li>
<li class="indent"><code><em>z-index: 50;</em></code></li>
<li><code>}</code></li>
<li>/* The shadow element */</li>
<li><code><strong>.shadow</strong> {</code></li>
<li class="indent"><code>background-color: #000;</code></li>
<li class="indent"><code>display: block;</code></li>
<li class="indent"><code><em>filter: progid:DXImageTransform.Microsoft.Blur</em>( makeShadow='true', pixelRadius=4, shadowOpacity=0.30 );</code></li>
<li class="indent"><code>height: 100%;</code></li>
<li class="indent"><code>left: 0;</code></li>
<li class="indent"><code><em>position: absolute;</em></code></li>
<li class="indent"><code>top: 0;</code></li>
<li class="indent"><code>width: 100%;</code></li>
<li class="indent"><code><em>z-index: 0;</em></code></li>
<li><code>}</code></li>
</ol>

<p>For some reason I got a more similar result with the <code>shadowOpacity</code> set to 30% instead of 20%.</p>

<h3>Where&rsquo;s the crux?</h3>

<p>If we are willing to ignore lots of bloated <acronym>CSS</acronym>: <strong><acronym>IE6</acronym> only blows the shadow up to 100% when the wrapper has a fixed height</strong>. This sucks, but unless you want to add more bloated code in JavaScript I don&rsquo;t know of any solution for this problem. Still <acronym>IE</acronym> 7-8 handle a value of 100% right, and there are many cases where the height is known. Take for example photos where you&#8217;d like to apply shadows, some buttons, or horizontal shades lying above images, like the <a href="http://dekabank.de/db/en/company/social-responsibility/">shadow of the second level navigation on this site</a>. Beautiful, isn&rsquo;t it?</p>
]]></content:encoded>
			<wfw:commentRss>http://learningtheworld.eu/2010/ms-box-shadow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embedding YouTube Video with iPhone Fallback</title>
		<link>http://learningtheworld.eu/2009/youtube-embed/</link>
		<comments>http://learningtheworld.eu/2009/youtube-embed/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 17:00:01 +0000</pubDate>
		<dc:creator><![CDATA[Martin Kliehm]]></dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[fallback]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[web standards]]></category>
		<category><![CDATA[XHTML]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://learningtheworld.eu/?p=729</guid>
		<description><![CDATA[Just a quick note as a reminder to myself <strong>how to embed YouTube videos</strong> in a standards compliant, valid <acronym title="Extensible Hypertext Markup Language">XHTML</acronym> syntax. It works across all current browsers, doesn&#8217;t use <code>&#60;embed&#62;</code>, and has the elegant fallback displaying a still image that is linked to YouTube, thus enabling iPhone users without Flash to view the video.]]></description>
				<content:encoded><![CDATA[<p>Just a quick note as a reminder to myself <strong>how to embed YouTube videos</strong> in a standards compliant, valid <acronym title="Extensible Hypertext Markup Language">XHTML</acronym> syntax. It works across all current browsers, doesn&rsquo;t use <code>&lt;embed&gt;</code>, and has the elegant fallback displaying a still image that is linked to YouTube, thus enabling iPhone users without Flash to view the video.</p>

<ol class="code">
<li><code>&lt;object type=&quot;application/x-shockwave-flash&quot; data=&quot;http://www.youtube.com/<span class="codeSpace">&nbsp;</span>v/<span class="codeSpace">&nbsp;</span><em>VideoID</em>&quot; width=&quot;480&quot; height=&quot;360&quot;></code></li>
<li class="indent"><code>&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/<span class="codeSpace">&nbsp;</span>v/<span class="codeSpace">&nbsp;</span><em>VideoID</em>&quot; /&gt;</code></li>
<li class="indent"><code>&lt;param name=&quot;quality&quot; value=&quot;high&quot; /&gt;</code></li>
<li class="indent"><code>&lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot; /&gt;</code></li>
<li class="indent"><code><strong>&lt;!-- Fallback content --&gt;</strong></code></li>
<li class="indent"><code>&lt;a href=&quot;http://www.youtube.com/<span class="codeSpace">&nbsp;</span>watch?<span class="codeSpace">&nbsp;</span>v=<em>VideoID</em>&quot;&gt;</code></li>
<li class="indent"><span class="indent"><code>&lt;img src=&quot;http://img.youtube.com/<span class="codeSpace">&nbsp;</span>vi/<span class="codeSpace">&nbsp;</span><em>VideoID</em>/0.jpg&quot; width=&quot;480&quot; height=&quot;360&quot; alt=&quot;[Video title]&quot; /&gt;<br />YouTube Video</code></span></li>
<li class="indent"><code>&lt;/a&gt;</code></li>
<li><code>&lt;/object&gt;</code></li>
</ol>

<p>Please note that there are spaces in the code above to allow linebreaks. If you copy and paste you need to remove those. <img src="http://learningtheworld.eu/wp-includes/images/smilies/icon_wink.gif" alt=";)" class="wp-smiley" /> </p>

<p>Here is an example:</p>

<p><object type="application/x-shockwave-flash" data="http://www.youtube.com/v/ybPeQUEgk-0" width="425" height="344">
<param name="movie" value="http://www.youtube.com/v/ybPeQUEgk-0" />
<param name="quality" value="high" />
<param name="allowFullScreen" value="true" />
<a href="http://www.youtube.com/watch?v=ybPeQUEgk-0">
<img src="http://img.youtube.com/vi/ybPeQUEgk-0/0.jpg" width="425" height="344" alt="Little 'Tinker Cartoon" />
YouTube Video
</a>
</object></p>
]]></content:encoded>
			<wfw:commentRss>http://learningtheworld.eu/2009/youtube-embed/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Oh, won&#8217;t somebody please think of the children!</title>
		<link>http://learningtheworld.eu/2008/somebody-please-think-of-the-children/</link>
		<comments>http://learningtheworld.eu/2008/somebody-please-think-of-the-children/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 21:30:00 +0000</pubDate>
		<dc:creator><![CDATA[Martin Kliehm]]></dc:creator>
				<category><![CDATA[W3C]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[web standards]]></category>
		<category><![CDATA[censorship]]></category>
		<category><![CDATA[children]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[cybersitter]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[ICRA]]></category>
		<category><![CDATA[label]]></category>
		<category><![CDATA[microformats]]></category>
		<category><![CDATA[PICS]]></category>
		<category><![CDATA[protection]]></category>
		<category><![CDATA[rating]]></category>
		<category><![CDATA[RDF]]></category>
		<category><![CDATA[search engines]]></category>
		<category><![CDATA[Semantic Web]]></category>
		<category><![CDATA[Tor]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://learningtheworld.eu/2008/somebody-please-think-of-the-children/</guid>
		<description><![CDATA[A little known <acronym title="World Wide Web Consortium">W3C</acronym> standard is the <strong>Platform of Internet Content Selection (<acronym>PICS</acronym>)</strong>. <acronym>PICS</acronym> is a system for self-labeling. Think of an early predecessor of the Semantic Web. Or in microformats it would be <em>hPorn</em>.&#160;[&#8230;]]]></description>
				<content:encoded><![CDATA[<p class="alert">Please note that the <acronym title="Platform of Internet Content Selection">PICS</acronym> standard has been superseded by <acronym title="Protocol for Web Description Resources">POWDER</acronym> in 2009. The old <acronym title="Resource Description Framework">RDF</acronym> code can be <a href="http://www.w3.org/TR/2009/NOTE-powder-primer-20090901/#ICRA1">included in a <acronym>POWDER</acronym> document</a>, though.</p>

<p>A little known <acronym title="World Wide Web Consortium">W3C</acronym> standard is the <strong><a href="http://www.w3.org/PICS/">Platform of Internet Content Selection</a> (<acronym>PICS</acronym>)</strong>. You can tell from the poor layout that it&rsquo;s a very old standard&nbsp;&mdash; in fact all of its parts are from 1996 and 1997. <acronym title="Oh my God">OMG</acronym>, that&rsquo;s <em>ancient!</em> That&rsquo;s even older than <acronym title="Hypertext Markup Language">HTML</acronym>&nbsp;4, <acronym title="Cascading Style Sheets">CSS</acronym>, or the Web Content Accessibility Guidelines!</p>

<p><strong><acronym>PICS</acronym> is a system for self-labeling.</strong> That raised some concerns about censorship in 1998, but governments who really want to censor their population&rsquo;s internet access have found more effective ways to block content (I, for one, can recommend <a href="https://www.torproject.org">Tor</a> as a countermeasure, also available as a Firefox extension, though I cannot guarantee your government approves it). So what remains is a meta element with information about your website, accompanied by a machine readable <acronym title="Resource Description Framework">RDF</acronym>/<acronym title="Extensible Markup Language">XML</acronym> file.</p>

<ol class="code">
<li><code>&lt;link rel=&quot;meta&quot; href=&quot;/<a href="/pics-label.rdf" type="application/rdf+xml">pics-label.rdf</a>&quot; type=&quot;application/rdf+xml&quot; title=&quot;ICRA PICS label&quot; /&gt;</code></li>
<li><code>&lt;meta <strong>http-equiv=&quot;pics-label&quot;</strong> content=&#39;(pics-1.1 &quot;http://www.icra.org/pics/vocabularyv03/&quot; l gen true for &quot;http://learningtheworld.eu&quot; r (n 0 s 0 v 0 l 1 oa 0 ob 0 oc 0 od 0 oe 0 of 0 og 0 oh 0 c 1))&#39; /&gt;</code></li></ol>

<p>Since in the nineties internet progress was driven by porn, <acronym>PICS</acronym> is mostly about <strong>child protection</strong>, although it can be used to describe a machine readable privacy statement and other things as well. Think of an early predecessor of the Semantic Web. Or in microformats it would be <em>hPorn</em>. Well, I assume very few of you run xxx sites, so why am I wasting your time with this post?</p>

<p>Because the <acronym>PICS</acronym> standard is most convenient when your website is <em>not</em> pornographic. The standard provides a way to label your website and distinguish between pictures of naked people as Greek ancient sculptures, in an educational or journalistic context, or as mere porn. But despite the name it&rsquo;s not only suitable for rating pictures, it&rsquo;s for text content or user-generated content as well, among other criteria. Plus the <acronym>PICS</acronym> label is <strong>recognized by Google</strong>, so it&rsquo;s not about rushing ahead and self-censoring to please our overlords, it&rsquo;s a measure to maximize the target audience and avoid mislead traffic. I believe a few of your clients may appreciate that. For example although this post uses quite a few trigger words, <acronym>PICS</acronym> provides a way to tell search engines and cybersitting software about the true nature of this article. I love that ability!</p>
]]></content:encoded>
			<wfw:commentRss>http://learningtheworld.eu/2008/somebody-please-think-of-the-children/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
