<?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>@drublic</title>
	<atom:link href="http://drublic.de/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://drublic.de/blog</link>
	<description>A Cutting Edge Webdesign Blog</description>
	<lastBuildDate>Thu, 17 May 2012 10:59:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title><![CDATA[SASS vs. LESS →]]></title>
		<link><![CDATA[http://css-tricks.com/sass-vs-less/]]></link>
		<comments>http://drublic.de/blog/sass-vs-less/#comments</comments>
		<pubDate>Thu, 17 May 2012 10:59:52 +0000</pubDate>
		<dc:creator>Hans Christian</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Preprocesors]]></category>
		<category><![CDATA[SASS]]></category>

		<guid isPermaLink="false">http://drublic.de/blog/?p=957</guid>
		<description><![CDATA[&#8220;Which CSS preprocessor language should I choose?&#8221; is a hot topic lately. I&#8217;ve been asked in person several times and an online debate has been popping up every few days it seems. It&#8217;s nice that the conversation has largely turned from whether or not preprocessing is a good idea to which one language is best. Let&#8217;s do this thing. Really short answer: SASS Slightly longer answer: SASS is better on a whole bunch of different fronts, but if you are already happy in LESS, that&#8217;s cool, at least you are doing yourself a favor by preprocessing. Chris Coyier finds an<p><a title="Link toSASS vs. LESS" class="more-link" href="http://drublic.de/blog/sass-vs-less/">Read more</a></p><p><a href="http://drublic.de/blog/sass-vs-less/" rel="bookmark" title="Permanent link to 'SASS vs. LESS'" class="glyph">&#9776;</a></p>
]]></description>
			<content:encoded><![CDATA[<blockquote><p>&#8220;Which CSS preprocessor language should I choose?&#8221; is a hot topic lately. I&#8217;ve been asked in person several times and an online debate has been popping up every few days it seems. It&#8217;s nice that the conversation has largely turned from whether or not preprocessing is a good idea to which one language is best. Let&#8217;s do this thing.</p>
<p>Really short answer: SASS</p>
<p>Slightly longer answer: SASS is better on a whole bunch of different fronts, but if you are already happy in LESS, that&#8217;s cool, at least you are doing yourself a favor by preprocessing.</p></blockquote>
<p>Chris Coyier finds an answer to what preprocessor is the better one by pointing out what the advantages of each preprocessor are. And as it turns out SASS is winning the race because it has more power and better features. So if you are asked why you use SASS, you might want to link people to this post.</p>
<p><a href="http://drublic.de/blog/sass-vs-less/" rel="bookmark" title="Permanent link to 'SASS vs. LESS'" class="glyph">&#9776;</a></p>
]]></content:encoded>
			<wfw:commentRss>http://drublic.de/blog/sass-vs-less/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Coding Style and Guidelines</title>
		<link>http://drublic.de/blog/my-coding-style-and-guidelines/</link>
		<comments>http://drublic.de/blog/my-coding-style-and-guidelines/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 07:45:18 +0000</pubDate>
		<dc:creator>Hans Christian</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Guidelines]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Markup]]></category>
		<category><![CDATA[SASS]]></category>

		<guid isPermaLink="false">http://drublic.de/blog/?p=878</guid>
		<description><![CDATA[After Harry Roberts published his HTML/CSS coding style I&#8217;ve decided to follow his call and write down how I like to code and what my guidelines for HTML and CSS coding are. This article is only a way to describe what I like to do – but it is by far not a recommendation or something. I have not really tried to “canalize” the coding style I do before but it is about time to do so and to write it down. Please let me know if you think that there are ways to do certain things better or in<p><a title="Link toMy Coding Style and Guidelines" class="more-link" href="http://drublic.de/blog/my-coding-style-and-guidelines/">Read more</a></p>]]></description>
			<content:encoded><![CDATA[<p>After Harry Roberts published his <a href="http://csswizardry.com/2012/04/my-html-css-coding-style/">HTML/CSS coding style</a> I&#8217;ve decided to follow his call and write down how I like to code and what my guidelines for HTML and CSS coding are.<br />
This article is only a way to describe what <em>I</em> like to do – but it is by far not a recommendation or something. I have not really tried to “canalize” the coding style I do before but it is about time to do so and to write it down. Please let me know if you think that there are ways to do certain things better or in a more understandable way through comments.</p>
<p>Harry points out some over all pretty solid ways to keep the markup readable which I use too. The major one is <strong>whitespace</strong>, I think. To be true, I <em>love</em> whitespace. But I&#8217;ll come to this later.</p>
<h2>General</h2>
<h3>Tabs or Spaces?</h3>
<p>Personally I&#8217;ve learned to use tabs instead of spaces just a few weeks ago. Lea Verou <a href="http://lea.verou.me/2012/01/why-tabs-are-clearly-superior/">lists up</a> some arguments, why she thinks using tabs is the way to go. But there are still some use-cases for spaces she describes.<br />
At <a href="http://gebruederheitz.de/">/gebrüderheitz</a> I&#8217;ve discussed using spaces with <a href="http://www.t3node.com/">Steffen</a> before. He works a lot with PHP and uses Tabs since… – ever! I have been using spaces because I ran into some difficulties with tabs in the past where code was totally wrong indented and stuff. But at the moment everything runs pretty smooth and I am happy with how it is.</p>
<h3>Lettercase</h3>
<p>HTML5 and CSS let you write code how ever you want to: UPPER-CASE, lower-case, CaMeL-cAsE. So this is all the same:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;section</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;a-lovely-header&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;contains-a-logo&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SECTION</span> <span style="color: #000066;">ID</span>=<span style="color: #ff0000;">&quot;A-LOVELY-HEADER&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;CONTAINS-A-LOGO&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SeCtIoN</span> <span style="color: #000066;">iD</span>=<span style="color: #ff0000;">&quot;a-LoVeLy-HeAdEr&quot;</span> <span style="color: #000066;">ClAsS</span>=<span style="color: #ff0000;">&quot;cOnTaInS-a-LoGo&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<p>You have to make sure you use the according class in CSS and id in JavaScript, because they are both case-sensitive.</p>
<p>I use lower-case exclusively. I&#8217;ve never tried to use anything different as it does not seem natural to me. Apart for that, WHO THE HELL WANTS SO READ UPPER-CASE ALL THE TIME?! IS THE CODE REALLY YELLING AT YOU? HAVE YOU EVER SEEN THIS IN A SERIOUS BOOK? Ok – to be fair, I&#8217;ve never seen a serious book with all lower case. But camel-case? C&#8217;mon…<br />
Camel-Case in JavaScript is totally perfect though.</p>
<h2>HTML</h2>
<p>Harry names a view key parts of HTML styling which I use and some I really do not like.</p>
<h3>Unquoted Attributes</h3>
<p>I <em>never</em> write unquoted attributes. Harry states that this is something he does, because he can. Well… That&#8217;s true. But as he points out he has some rules where he quotes attributes for example for generated content or content that changes a lot.</p>
<p>His opinion on using double-quotes for all the attributes is obvious, anyway:</p>
<blockquote><p>It is more consistent on the whole, but by introducing rules I make my own consistency; if you can get away with not using quotes, then do so.</p></blockquote>
<p>For me the rule “Don&#8217;t confuse others” applies here: When another programmer who is not familiar with writing attributes without quotes has to edit my code in a later stage of a project or just when checking the source of a project and sees this, she might be confused with what I wrote.<br />
Apart for that, writing attributes without quotes is error-prone.</p>
<p><strong>An example:</strong> You use the <a href="http://www.stubbornella.org/content/2010/06/25/the-media-object-saves-hundreds-of-lines-of-code/">Media Object</a> as described by Nicole Sullivan for your styles and need a button, you will probably add a class <code>btn</code> to your link. The action that this button takes care of is the primary target of a website. Thus you add another class <code>primary-btn</code> to the <code>class</code>-attribute. If you don&#8217;t use quotes, you&#8217;ll have to add them now. It may occur that you forget them. And now what?! You are screwed. This will lead into searching your template over and over again until you find this nasty little mistake you made earlier. I don&#8217;t want this! I like code that&#8217;s pretty much straightforward.</p>
<p>To be fair I have to say, that I use a build script for my code before it goes into production which minifies my HTML-code and thus removes unnecessary quotes. But this does not change my development coding style.</p>
<h3>Self-Closing Tags</h3>
<p>Omitting self-closing tags is a thing I really love about HTML (over XHTML). You can omit the closing tag. Actually I&#8217;ve seen people not using self-closing tags on images or inputs but using them in meta-tags. I don&#8217;t know what the sense behind this might be.<br />
I just do not use them anywhere.</p>
<h3>Optional Closing Tags</h3>
<p>This is a thing people may get confused about, too. Just a view days ago someone <a href="https://github.com/h5bp/html5-boilerplate/pull/1058">re-filed the issue of missing closing tags</a> for HTML5 Boilerplate&#8217;s 404-error-page template because he was confused of the missing stuff I guess. That&#8217;s why I try to always use the optional closing tags – again: don&#8217;t confuse anyone. At least I <em>try</em> to.</p>
<p>I remember Paul Irish had a great usage of optional closing tags for tables where you can align rows by using whitespace, so you can see the table&#8217;s layout in HTML. Not working with generated data, though.</p>
<p>Here&#8217;s the example</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;table<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tr<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;th<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Name           <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;th<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Country       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;th<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Nonsense
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tr<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Rick Astley    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>England       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Rickrolling
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tr<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Chuck Norris   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>United States <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Roundhouse-Kick
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tr<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Emeli Sandé    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Scotland      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Singin – Fo realz!
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/table<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h3>Whitespace</h3>
<p>Oh yeah, whitespace. As I already pointed out I <em>love</em> whitespace in my code. Everything is a bit more obvious when you divide it into small parts. It gets easier to scan the code I think. Comments help with this too.<br />
I like to divide bigger chunks of a page with a lot of whitespace. For example if you have a content-area and a sidebar, I try to keep them separate by using whitespace.<br />
Apart from that grouping elements like definition-list-entries helps a lot with the readability of code.</p>
<p>I&#8217;ve made a gist with <a href="https://gist.github.com/2466291">an example-file</a>. Check it.</p>
<h2>CSS</h2>
<p>Using ids in CSS is something I try to avoid but it strikes me sometimes and I just do it if there are already ids defined on some elements. Mostly these are identifiers for header- or footer-sections. But I think it&#8217;s better use classes for styling concernes and ids for JavaScript and other stuff.</p>
<p>Anyway… The next part will not be about vanilla CSS. I use <strong>SASS</strong> (SCSS) nowadays and recently re-factored a corporate website for one of our customers at /gebrüderheitz in SASS. I want to share the way I worked with a lot of CSS in this case and did it sometimes before.</p>
<h3>Structure</h3>
<p>The website has a lot of styles which had to be refactored. These were organized in one big file that has about three thousand lines of code. I do not like to have a file that has so many code and is not clear by looking at it at first.<br />
So I have decided to split up several parts into different files.</p>
<p>Before the refactoring we made an online style-guide, defining the elements that appear on the side. This style-guide will be used in other projects for the same customer, too and is essential for a corporate website. We tried to define as much as possible but also let designers have a free hand at what they do.</p>
<p>For all SASS-files I use a folder-structure which looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">+ CSS
  + elements
  + helpers
  + modules
  + page
  styles.scss</pre></div></div>

<p>The <code>styles.scss</code> file has a brief description of the project, who wrote the styles (copyright…) and includes (with <code>@include</code>) all other files which lie in the created folders.</p>
<h4>+ helpers</h4>
<p><code>helpers</code> contains a file with pre-defined mixins, another file with all the variables for the project, a reset (in my case this is most of the HTML5 Boilerplate CSS, which contains <a href="http://necolas.github.com/normalize.css/">Normalizer.css</a>) and some other helper-classes which I use via mixins or with SASS&#8217; <code>@extend</code>-method.</p>
<h4>+ elements</h4>
<p>In the element folder I include files with styles for styling native HTML elements. I&#8217;ve got a file named <code>typography</code> which contains definitions for the general copy-text, headlines, links, quotes aso. Another file contains all stylings that are connected to lists in the content (unordered-, ordered- and definition-lists). This folder also includes the styles for forms and tables.</p>
<h4>+ modules</h4>
<p>I mentioned the style-guide we defined for this project. This was a great help for me when dividing the CSS into parts because I was able to see which modules were needed for the page: boxes, a paginator, <a href="http://drublic.de/blog/how-to-build-accordion-using-css-and-jquery/">an accordion menu</a>, the navigation and some other stuff.<br />
For each module I have an own file which contains the styles of only one modules. So when I need to change something that has to do with the paginator, I&#8217;ll head over to the according file and change the desired values. This saves me a lot of searching and scrolling through a file. Apart from that, Sublime Text&#8217;s “Find in files” (cmd + Shift + F) feature lets you search trough all files in a project which is pretty handy. Text Mate has something similar I think. And if your editor does not support it, fire up the console and <code>grep</code> for the things you want to find.</p>
<h4>+ page</h4>
<p>This last folder contains all files that add a separate styling for any page or part of the website. Typical content might be the general layout and the header and footer styling for a page. Furthermore I define styles for an area of a website in this folder – e.g. if events need more styles than defined in the modules section, or a contact-form that has some extended stylings.</p>
<h4>And More?</h4>
<p>We have not yet done the styling for the mobile version of this website and thus the styles are not yet included into the project&#8217;s folder structure. Styles that are specific for devices with smaller width will go into a <code>mobile</code>-folder.<br />
Another thing are stylesheets for print or other media. I&#8217;ve not yet found a proper way to include these. If you have any idea for this, let me know.</p>
<h3>Whitespace &amp; Comments</h3>
<p>Back to the main CSS styling guidelines for my projects.</p>
<p>Typically I try to avoid too much rulesets in one file but sometimes you need to do this to not split one feature into several files, which is not the sense behind this modal.<br />
Comments are a thing that help everyone reading the defined styles to unterstand them better. Most of the class names are pretty obvious and thus don&#8217;t require any further explanation. But if you define styles that are not obvious at the first glance or you need to use browser-hacks in any form it can be helpful for other programmers to include a short comment. At least I do it this way.<br />
I try to think about “other programmers” as the programmer I might have become in three month, when I will look at the defined styles again. If <em>I</em> don&#8217;t know what I did three month ago, how is anyone else supposed to understand it. This needs to be avoided.</p>
<h3>Formatting</h3>
<p>One thing Harry mentions is that he does not use a lot of whitespace in his rulesets. I am allergic of this style of writing. I like to have really clean styles as this:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.some-rule</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#666</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>For vendor <strong>prefixes</strong> he indents every rule so he can use typing in columns. As I use SASS I don&#8217;t really have to care about this. But I like the way he does it. I&#8217;ve done it the same way when I used to write vanilla CSS.</p>
<p><strong>Indenting</strong> is somehow essential for <a href="http://drublic.de/blog/the-css-hierarchies-module-level-3/">the CSS nesting</a> in SASS. For rules where the nesting does not work I don&#8217;t indent though.</p>
<h2>And A Lot More</h2>
<p>This is not everything that applies to my HTML and CSS workflow / guidelines. I hope I can write more about stuff like this in the future and share more of my thoughts. Feedback on my thoughts would be great.</p>
<p>Also: If you have some time, write down what your way of coding is. Share it on Twitter with the hashtag <a href="https://twitter.com/#!/search/realtime/%23codestyle">#codestyle</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://drublic.de/blog/my-coding-style-and-guidelines/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title><![CDATA[RECESS – A CSS cleaning tool build on top of LESS →]]></title>
		<link><![CDATA[http://twitter.github.com/recess/]]></link>
		<comments>http://drublic.de/blog/twitter-recess-css-cleaning-tool-build-on-less/#comments</comments>
		<pubDate>Tue, 17 Apr 2012 22:25:15 +0000</pubDate>
		<dc:creator>Hans Christian</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Build Tool]]></category>
		<category><![CDATA[LESS]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://drublic.de/blog/?p=867</guid>
		<description><![CDATA[Developed at Twitter to support our internal styleguide, RECESS is a simple, attractive code quality tool for CSS built on top of LESS. Incorporate it into your development process as a linter, or integrate it directly into your build system as a compiler, RECESS will keep your source looking clean and super managable. As I think reading the source is essential for developers to become good at what they do viewing this source in readable style is essential too. RECESS is a tool which helps you developing good-looking CSS with LESS. It is developed at Twitter and has now been<p><a title="Link toRECESS – A CSS cleaning tool build on top of LESS" class="more-link" href="http://drublic.de/blog/twitter-recess-css-cleaning-tool-build-on-less/">Read more</a></p><p><a href="http://drublic.de/blog/twitter-recess-css-cleaning-tool-build-on-less/" rel="bookmark" title="Permanent link to 'RECESS – A CSS cleaning tool build on top of LESS'" class="glyph">&#9776;</a></p>
]]></description>
			<content:encoded><![CDATA[<blockquote><p>Developed at Twitter to support our internal styleguide, RECESS is a simple, attractive code quality tool for CSS built on top of LESS.</p>
<p>Incorporate it into your development process as a linter, or integrate it directly into your build system as a compiler, RECESS will keep your source looking clean and super managable.</p></blockquote>
<p>As I think reading the source is essential for developers to become good at what they do viewing this source in readable style is essential too. RECESS is a tool which helps you developing good-looking CSS with LESS. It is developed at Twitter and has now been open-sourced.</p>
<p>RECESS is a Node.js module and is maintained by <a href="https://twitter.com/fat">@fat</a>. You can find out more about it by viewing the source <a href="https://github.com/twitter/recess">at GitHub</a>.</p>
<p>BTW: I&#8217;ve decided to not minimize and concatenate my blog&#8217;s source anymore. So, feel free to dig deep!</p>
<p><a href="http://drublic.de/blog/twitter-recess-css-cleaning-tool-build-on-less/" rel="bookmark" title="Permanent link to 'RECESS – A CSS cleaning tool build on top of LESS'" class="glyph">&#9776;</a></p>
]]></content:encoded>
			<wfw:commentRss>http://drublic.de/blog/twitter-recess-css-cleaning-tool-build-on-less/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>About CSS Variables</title>
		<link>http://drublic.de/blog/about-css-variables/</link>
		<comments>http://drublic.de/blog/about-css-variables/#comments</comments>
		<pubDate>Sun, 18 Mar 2012 15:07:54 +0000</pubDate>
		<dc:creator>Hans Christian</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS WDs]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Specification]]></category>
		<category><![CDATA[Working Draft]]></category>

		<guid isPermaLink="false">http://drublic.de/blog/?p=805</guid>
		<description><![CDATA[Please read about the updated syntax of CSS variables in the first update of this post. Since a little bit more than a month (as of the time of writing) there is a Editor&#8217;s Draft for a CSS Variables Module by Google (Tab Atkins and Luke Macpherson) and Daniel Glazman. Just a few days ago the Working Draft was updated. The first draft was written in 2008 by Daniel Glazman but was not added to the official specification. The new WD extends this proposal by Glazman. Disclaimer: This article is part of a small series about the latest CSS working<p><a title="Link toAbout CSS Variables" class="more-link" href="http://drublic.de/blog/about-css-variables/">Read more</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>Please read about the updated syntax of CSS variables in <a href="#update">the first update</a> of this post.</strong></p>
<p>Since a little bit more than a month (as of the time of writing) there is a <a title="CSS Variables Module Level 1" href="http://dev.w3.org/csswg/css-variables/">Editor&#8217;s Draft for a CSS Variables Module</a> by Google (<a href="http://www.xanthir.com/blog/">Tab Atkins</a> and Luke Macpherson) and <a href="http://glazman.org/weblog/">Daniel Glazman</a>. Just a few days ago the Working Draft was updated.<br />
The <a href="http://disruptive-innovations.com/zoo/cssvariables/">first draft was written in 2008</a> by Daniel Glazman but was not added to the official specification. The new <abbr title="Working Draft">WD</abbr> extends this proposal by Glazman.</p>
<p><strong>Disclaimer:</strong> This article is part of a <a href="http://drublic.de/blog/category/css-wds/" title="A series of posts which describes new CSS specifications, working drafts and editor’s drafts.">small series</a> about the latest CSS working drafts. The first article in this series was about the <a title="About The CSS Hierarchies Module Level 3" href="http://drublic.de/blog/the-css-hierarchies-module-level-3/">CSS Hierarchies Module</a>.</p>
<h2>CSS Variables</h2>
<p>The CSS Variables Module Level 1 suggests to use variables for data that is reused in stylesheets. These key-value storages provide the possibility to store &#8220;meaningless&#8221; data as you can do in HTML: Variable keys consist of a <code>data-</code>-prefix and the variable name.</p>
<blockquote><p>Any property name starting with the prefix &#8220;data-&#8221; is a data property. Data properties are defined to be valid but meaningless as they are meant solely for allowing authors to pass custom data around their page, similar to the custom data attributes in HTML.<br />
<cite>~ <a href="http://dev.w3.org/csswg/css-variables/#defining-variables">Defining Variables With Data Properties</a> &#8211; CSS Variables Editor&#8217;s Draft</cite>
</p></blockquote>
<p>Using <code>data-</code> as a prefix for variables is <a href="https://twitter.com/#!/tabatkins/status/170547807445467136">still in discussion</a> and may likely be changed to something more &#8220;connected&#8221; to variables (<code>$</code> or <code>&#038;</code>).</p>
<p><strong>Edit:</strong> The mailing-list www-style <a href="http://lists.w3.org/Archives/Public/www-style/2012Feb/1028.html">is discussing</a> the use of <code>data</code> and Ian Muir wrote <a href="http://www.piehead.com/blog/2012/03/a-vote-for-css-variables">an article</a> about the problem.</p>
<h3>Syntax</h3>
<p>Variables are defined by mapping them to the <code>:root</code> pseudo-class. The WD does not really explain why the variables must be declared on the root-element. Maybe it&#8217;s because the data needs to be bound to an element to not &#8220;fly around&#8221; in the global scope (which does not really exist in CSS).<br />
Defined variables can also be set on every other element and overwrite the existing value of a variable.<br />
So this is how you set variables.</p>
<p>To get a specific variable, you do not declare the variable-name but you call <code>data</code> as a function on a certain property with the variables name (without <code>data-</code>-prefix) as an argument.</p>
<h3>An Example</h3>
<p>So here is an example:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* Set data */</span>
<span style="color: #3333ff;">:root </span><span style="color: #00AA00;">&#123;</span>
  data-main-<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#bada55</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* Get data */</span>
<span style="color: #6666ff;">.foobar</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> data<span style="color: #00AA00;">&#40;</span>main-<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>As said before, variables can be overwritten for specific elements. So we can add the declaration of the variable to <code>.foobar</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.foobar</span> <span style="color: #00AA00;">&#123;</span>
  data-main-<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fe57a1</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> data<span style="color: #00AA00;">&#40;</span>main-<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>The color of <code>.foobar</code> is now <code>#fes7a1</code> and not <code>#bada55</code>.</p>
<h2>Real World Examples</h2>
<p>Well, as this is an Editor&#8217;s Draft and pretty new it&#8217;s not being implemented in any browser.</p>
<p>I&#8217;ve created <a href="http://dabblet.com/gist/2072596" title="A CSS variables test">a test case on dabblet</a> with vendor prefixes which tests the two examples above. I&#8217;ve run this test on the major browser alphas and nightlies.</p>
<p>Even though variables are not natively supported by CSS in any browser yet, we can use a very similar approach: All CSS preprocessors support variables. Here is an example with SASS:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* Setting a variable */</span>
$main-<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#bada55</span><span style="color: #00AA00;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* Get the variable's value */</span>
<span style="color: #6666ff;">.foobar</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> $main-<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h2>Conclusion</h2>
<p>We can use variables with preprocessors today which is pretty rad. As with <a href="http://drublic.de/blog/the-css-hierarchies-module-level-3/">the CSS Hierarchies Module</a> CSS in the future may support ideas that come from implementations in preprocessors somehow.<br />
I think most developers are happy about these adoptions and will likely use it. But as it will take some time for all vendors to implement this feature – and <a href="http://paulirish.com/2011/browser-market-pollution-iex-is-the-new-ie6/" title="Paul Irish about problems with oldIE">even more time until browsers that don&#8217;t support such new features vanish</a> – we will have to use preprocessors to get variables in our CSS working.</p>
<hr />
<h2 id="update">Update <small>16.04.2012</small></h2>
<p>Since last week the CSS Variables Module Level 1 is an <a href="http://www.w3.org/TR/css-variables/">actual Working Draft of the W3C</a>.</p>
<p>It&#8217;s now possible to define variables with the <code>var</code>-prefix instead of <code>data</code> which is still pretty complicated. I wonder why they not adept an existing concept as in LESS or SASS.</p>
<p>Thus the <code>data()</code>-function changed accordingly to <code>var()</code>.</p>
<p>Furthermore it&#8217;s possible to set variables on a certain element but use them in a more complex definition. An example might be the usage as follows (while elements with class <code>important</code> and <code>primary</code> are <code>div</code>s):</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.important</span> <span style="color: #00AA00;">&#123;</span> var-<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">red</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.primary</span> <span style="color: #00AA00;">&#123;</span> var-<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">blue</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
div <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> var<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Also nestings for variables are possible:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #3333ff;">:root </span><span style="color: #00AA00;">&#123;</span>
  var-<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ddd</span><span style="color: #00AA00;">;</span>
  var-<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> var<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h3>The bright and shiny future</h3>
<p>As I think there still are some issues with this Working Draft I like the fast step forward in making this a WD in only a view weeks.<br />
So sooner or later variables will be part of the CSS specification and will be implemented in browsers. I hope this will be very soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://drublic.de/blog/about-css-variables/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>About The CSS Hierarchies Module Level 3</title>
		<link>http://drublic.de/blog/the-css-hierarchies-module-level-3/</link>
		<comments>http://drublic.de/blog/the-css-hierarchies-module-level-3/#comments</comments>
		<pubDate>Fri, 17 Feb 2012 14:52:23 +0000</pubDate>
		<dc:creator>Hans Christian</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS WDs]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Preprocessors]]></category>
		<category><![CDATA[Specification]]></category>

		<guid isPermaLink="false">http://drublic.de/blog/?p=771</guid>
		<description><![CDATA[Since the beginning of February there were some proposals for the CSS3 specification. These proposals are not yet part of the specification and will likely be changed until they get adopted by the CSSWG. One of these drafts is the CSS Hierarchies Module Level 3. So what&#8217;s the Hierarchies Module? And why &#8220;Level 3&#8243;? The Hierarchies Module is not exactly new. It exists since the very first steps of CSS and was first released in Dezember 1996 with CSS1. The CSS1 specification is still up, so check it out if you want to. When you write CSS you always use selectors to target<p><a title="Link toAbout The CSS Hierarchies Module Level 3" class="more-link" href="http://drublic.de/blog/the-css-hierarchies-module-level-3/">Read more</a></p>]]></description>
			<content:encoded><![CDATA[<p>Since the beginning of February there were some proposals for the CSS3 specification. These proposals are not yet part of the specification and will likely be changed until they get adopted by the <a title="The CSS Working Group Wiki" href="http://wiki.csswg.org/">CSSWG</a>. One of these drafts is the <a title="The CSS Hierarchies Module Level 3" href="http://dev.w3.org/csswg/css3-hierarchies/"><strong>CSS Hierarchies Module Level 3</strong></a>.</p>
<h2>So what&#8217;s the Hierarchies Module? And why &#8220;Level 3&#8243;?</h2>
<p>The Hierarchies Module is not exactly new. It exists since the very first steps of CSS and was first released in Dezember 1996 with CSS1. The <a title="Cascading Style Sheets, Level 1" href="http://www.w3.org/TR/2008/REC-CSS1-20080411/">CSS1 specification</a> is still up, so check it out if you want to.</p>
<p>When you write CSS you always use selectors to target the element you want to style. This works pretty much straight-forward: The right-most simple selector is the one which get the declarations assigned that are defined in the ruleset.<br />
These selectors define a certain hierarchy in your stylesheet.<br />
<strong>Note:</strong> Please make sure to read Tab Atkins&#8217; <a title="CSS Spec Terms, for Future Reference" href="http://www.xanthir.com/blog/b4E50">Reference for CSS Spec Terms</a>.</p>
<h3>An example</h3>
<p>Today you would target some links in a navigation like this:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#nav</span> ul li a <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>If you&#8217;re smart and your markup allows you to do so, you may write:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#nav</span> a <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>The li-elements need to be inlined as you want a horizontal navigation:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#nav</span> ul li <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Furthermore the navigation should be aligned on the right and all the links centered:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#nav</span> ul <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#nav</span> ul li <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>This leaves us with a lot of repetition for the selectors.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#nav</span> ul <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#nav</span> ul li <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#nav</span> ul li a <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>With the Level 3 proposal by <a title="Tab Atkins on Twitter" href="https://twitter.com/#!/tabatkins">Tab Atkins Jr</a> and <a title="Shane's Google+ profile-page" href="https://plus.google.com/101031566089926386443/posts">Shane Stephens</a> (working for Google) this is about to get a little bit easier. The existing system will be extended with some new functionality. This is why it&#8217;s called Level 3. (Also it will likely be part of CSS <strong>3</strong> – and not 4 or 10 or something.)</p>
<h2>What&#8217;s new in there?</h2>
<p>Lately you saw the rise of CSS Preprocessors. Everyone <a title="Lea Verou - On CSS preprocessors" href="http://lea.verou.me/2011/03/on-css-preprocessors/">has</a> <a title="Chris Coyier - Musings on Preprocessing" href="http://css-tricks.com/musings-on-preprocessing/">an opinion</a> <a title="Andy Clark - LESS" href="http://www.stuffandnonsense.co.uk/blog/about/less">on this</a>. The thing why so many developers use them is that they help to organize the CSS-code you are writing.<br />
Preprocessors have brought up another idea of CSS hierarchies. And with the <strong>CSS Hierarchies Module Level 3</strong> this has been adopted.</p>
<p>The specification draft allows you to nest your rules and use the <code>&amp;</code>-character to reference a parent selector in a certain rule.</p>
<p>Here&#8217;s the example from above with the new hierarchy:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#nav</span> ul <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span>
    &amp; li <span style="color: #00AA00;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
        &amp; a <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
    <span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>As you can see there are no repetitions for the selectors as you can reference them by just writing <code>&amp;</code> and nest them properly.</p>
<h2>How can we use this today and when will it be ready for the &#8220;real world&#8221;?</h2>
<p>As you may guess this is not implemented in any browser yet.</p>
<p>As this spec is written by two Google-guys it&#8217;s likely that this will be implemented in Chrome in the near future. At the moment this is not working with Chrome 19 (Canary) or WebKit Nightly.<br />
I&#8217;ve made <a title="Testing the CSS Hierarchies Module Level 3" href="http://dabblet.com/gist/1854033">this Dabblet</a> to check if the module is supported in a browser or not. caniuse.com does not provide any data for the Hierarchies Module yet.<br />
<strong>Aside</strong>: Check my <a title="The Dabbles App for Google Chrome" href="http://drublic.de/blog/dabblet-chrome-app/">Dabblet Chrome App</a> to view all your latest dabblets if you&#8217;re a Chrome user.</p>
<p>Tab Atkins proposed another style for nesting. To reference the parent selector you use <code>@this</code> instead of the <code>&amp;</code>-character. Peter Beverloo<a title="CSS Variables and mixins, Interactive Validation and pre-rendering" href="http://peter.sh/2011/01/css-variables-and-mixins-interactive-validation-and-prerendering/"> wrote about this</a> a year ago. Also Tab Atkins <a title="CSSOM, Vars, Mixins, Nesting, and Modules" href="http://www.xanthir.com/blog/b49w0">has an article</a> about his further plans. This variant was not implement either and is replaced with the new draft for the specification. Anyway <a title="Using CSS nesting with @this" href="http://dabblet.com/gist/1853580">you could view</a> the dabblet I&#8217;ve made for this propose.</p>
<h3>Preprocessors</h3>
<p>As mentioned above CSS preprocessors offer the chance to use something like hierarchies in there own way. Here are two examples:</p>
<p><strong>SCSS (aka. SASS)</strong></p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#nav</span> ul <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span>
    li <span style="color: #00AA00;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
        a <span style="color: #00AA00;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
            &amp;<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">gray</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
        <span style="color: #00AA00;">&#125;</span>
    <span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p><strong>Stylus</strong></p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#nav</span> ul
    <span style="color: #000000; font-weight: bold;">text-align</span> <span style="color: #000000; font-weight: bold;">right</span>
    li
        <span style="color: #000000; font-weight: bold;">display</span> <span style="color: #993333;">inline</span>
        a
            <span style="color: #000000; font-weight: bold;">color</span> <span style="color: #cc00cc;">#000</span>
            &amp;<span style="color: #3333ff;">:hover
                </span><span style="color: #000000; font-weight: bold;">color</span> grey</pre></div></div>

<p>As you can see there is a difference in how preprocessors treat the <code>&amp;</code>-character as a reference: In the CSS specification draft <code>&amp;</code> is obligatory in every nested rule you write to reference the parent selector. Preprocessors need them only if there is a pseudo-class or -element or a combinator (such as <code>~</code> or <code>&gt;</code>) used for a specific selector.</p>
<p>As I stated in the introduction it may happen that the specification will be changed until it becomes final or is adopted by the CSS Working Group. I recommend you follow the discussions about this topic in order to stay up to date.<br />
When this specification will be implemented by one of the browser vendors it&#8217;s just a matter of weeks until it will be adopted by the others I guess.</p>
<p>But, as the draft states, this is not yet part of CSS:</p>
<blockquote><p>This document is purely an Editor&#8217;s Draft. It has not yet been adopted by the Working Group, and should not be considered to be part of CSS.</p>
<p>~ <a title="Status" href="http://dev.w3.org/csswg/css3-hierarchies/#status">CSS Hierarchies Module &#8211; Status</a></p></blockquote>
<h2>Opinion</h2>
<p>Personally I hope that referencing the parent selector with <code>&amp;</code> will not be in the final specification as it is now. It&#8217;s not needed as the rules are nested anyway and preprocessors nowadays treat them better.</p>
<p>Anyway the new nesting is pretty useful as it reduces the redundancy of writing selectors in CSS. In connection with other upcoming specifications like the <a title="CSS Variables Module Level 1" href="http://dev.w3.org/csswg/css-variables/">CSS Variables Module Level 1</a> this is what is needed and will be helpful for every web-developer once it will be implemented in browsers.</p>
]]></content:encoded>
			<wfw:commentRss>http://drublic.de/blog/the-css-hierarchies-module-level-3/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Dabblet Chrome App</title>
		<link>http://drublic.de/blog/dabblet-chrome-app/</link>
		<comments>http://drublic.de/blog/dabblet-chrome-app/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 10:26:13 +0000</pubDate>
		<dc:creator>Hans Christian</dc:creator>
				<category><![CDATA[Apps]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[References]]></category>
		<category><![CDATA[AMD]]></category>
		<category><![CDATA[App]]></category>
		<category><![CDATA[Chrome App]]></category>
		<category><![CDATA[dabblet]]></category>
		<category><![CDATA[Reference]]></category>

		<guid isPermaLink="false">http://drublic.de/blog/?p=748</guid>
		<description><![CDATA[I think all of you know Lea Verou&#8217;s dabblet. dabblet is an interactive playground for quickly testing snippets of CSS and HTML code. It uses -prefix-free, so that you won&#8217;t have to add any prefixes in your CSS code. You can save your work in Github gists, embed it in other websites and share it with others. ~ About dabblet Some time ago I made this tiny Google Chrome App for jsFiddle which is in case just a bookmarklet with a bigger icon. I did this for dabblet, too but extended the app to something more: It displays all your dabblets<p><a title="Link toDabblet Chrome App" class="more-link" href="http://drublic.de/blog/dabblet-chrome-app/">Read more</a></p>]]></description>
			<content:encoded><![CDATA[<p><img src="http://drublic.de/blog/wp-content/uploads/2012/01/dabblet-128x128.png" alt="Dabblet Chrome App" title="Dabblet Chrome App" width="128" height="128" class="alignright"></p>
<p>I think all of you know Lea Verou&#8217;s <i>dabblet</i>.</p>
<blockquote><p><i>dabblet</i> is an interactive playground for quickly testing snippets of CSS and HTML code. It uses -prefix-free, so that you won&#8217;t have to add any prefixes in your CSS code. You can save your work in Github gists, embed it in other websites and share it with others.<br />
<cite>~ <a href="http://dabblet.com/help/" target="_blank">About <i>dabblet</i></a></cite>
</p></blockquote>
<p>Some time ago I made <a href="https://chrome.google.com/webstore/detail/hiigmadmngbpbmacbkfngpkjfmmpagfk" title="jsFiddle Chrome App on the App Store" target="_blank">this tiny</a> Google Chrome App for jsFiddle which is in case just a bookmarklet with a bigger icon.</p>
<p>I did this for <i>dabblet</i>, too but extended the app to something more: It displays all your dabblets with title and creation-date. You can then visit your dabblet directly.</p>
<p>You can find the app in the Google Chrome App store now.</p>
<p><a href="https://chrome.google.com/webstore/detail/ehlimmpmogmglpfidpkbocdblhlnofke" title="Download the App in the Google Chrome App Store" class="button" target="_blank">Download</a></p>
<p>This project <a href="https://github.com/drublic/dabblet-chrome-app" title="Find the Chrome App on GitHub" target="_blank">is on GitHub</a>, so please feel free to contribute and <a href="https://github.com/drublic/dabblet-chrome-app/issues" title="Report bugs and feature requests on GitHub" target="_blank">report bugs and feature requests</a>.</p>
<h2 id="changelog">Changelog</h2>
<p>These are the major changes. All commits can be found <a href="https://github.com/drublic/dabblet-chrome-app/commits/master" title="Commit History for the Chrome App - dabblet">on GitHub</a>.</p>
<p><strong>v0.7</strong> &#8211; Feb. 13, 2012</p>
<ul>
<li>Add search – <a href="https://github.com/drublic/dabblet-chrome-app/issues/2">#2</a></li>
<li>Rewrite code-basis based on JS AMD with <a href="http://requirejs.org/" title="RequireJS">RequireJS</a></li>
<li>Display message if user has no gists to display – <a href="https://github.com/drublic/dabblet-chrome-app/issues/3">#3</a></li>
</ul>
<p><strong>v0.45</strong> &#8211; Feb. 02, 2012</p>
<ul>
<li>Add a link to fork Gists on dabblet when visiting <a href="https://gist.github.com">them on GitHub</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://drublic.de/blog/dabblet-chrome-app/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>About Git&#8217;s Cherry-Picking</title>
		<link>http://drublic.de/blog/about-gits-cherry-picking/</link>
		<comments>http://drublic.de/blog/about-gits-cherry-picking/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 09:30:03 +0000</pubDate>
		<dc:creator>Hans Christian</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[cherry-picking]]></category>
		<category><![CDATA[Organize Code]]></category>
		<category><![CDATA[Version Control]]></category>
		<category><![CDATA[work together]]></category>

		<guid isPermaLink="false">http://drublic.de/blog/?p=733</guid>
		<description><![CDATA[At /gebrüderheitz we use Git as a version control system as we think this is the best to work together on a level which is easy to learn and work with. Before we used Git we’ve used SVN but this is by far not as flexible as Git. There are enough posts gathering the difference between Git and SVN so I will not cover any of these. When working in a team it’s important to keep your different stages of development in sync and control somehow: There is a front-end development going on which is in deep connection with the<p><a title="Link toAbout Git's Cherry-Picking" class="more-link" href="http://drublic.de/blog/about-gits-cherry-picking/">Read more</a></p>]]></description>
			<content:encoded><![CDATA[<p>At <a href="http://gebruederheitz.de/">/gebrüderheitz</a> we use Git as a version control system as we think this is the best to work together on a level which is easy to learn and work with.</p>
<p>Before we used Git we’ve used SVN but this is by far not as flexible as Git. There are enough posts gathering the difference between Git and SVN so I will not cover any of these.</p>
<p>When working in a team it’s important to keep your different stages of development in sync and control somehow: There is a front-end development going on which is in deep connection with the server-side development; you may also want to develop a new sub-project within your main project; and then there is a tested and fully working live-version of a project.</p>
<p>With Git it’s pretty obvious to use branches to organize different states of the project’s development.</p>
<h2>Branches</h2>
<p>Branches can consist of the whole project’s files and some more commits covering a specific issue or feature. Also they can show a whole different approach of a project and do not necessarily need to consist of the main project’s files.</p>
<p>For our projects we try to keep these branches tight so we will not have a problem when it comes to merging branches – to let one feature or development approach flow into the main development line. Keep in mind that branches in a project are indeed cheap. So use them where you think they might fit. Don’t think about it to long. It will help you in your whole working-process.</p>
<h2>Cherry-Picks</h2>
<p>Sometimes, when it comes to bug fixing you don’t want to put fixes in your live-branch. You fix them in your development-branch and commit them over there. The dev-branch might be on a whole other level as your live branch as you’ve developed some things that will be part of a next major update or so. Therefore Git’s cherry-picking has become a perfect addition to our workflow.</p>
<p>With cherry-picking you are able to pull single commits from one branch to another.</p>
<p>Another part where you might want to use cherry-picking is when a colleague and you develop in two different branches and one contributes to the other’s sub-project without changing the branch. There are some other use cases. Please feel free to share where you use cherry-picking through the comments.</p>
<h2>How to Use Cherry-Picking</h2>
<p>I am using a GUI for doing all the Git-related stuff which is pretty handy and easy. But I think it is important to know how to handle Git via the console anyway.</p>
<p>Here is how to cherry-pick commits.</p>
<p>At first you need to commit your changes in the development branch.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">'This is some bugfix-message'</span></pre></div></div>

<p>You now need the commit-hash for the commit you want to cherry-pick in another branch.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> log <span style="color: #660033;">-1</span></pre></div></div>

<p>This will return the meta-data for your latest commit. You can now copy the first 7 or so numbers of the commit-hash. It’s not necessary to copy the whole hash as the hash-partial only needs to be unique above all commits of the project.</p>
<p>Now you need to change your checked out branch to the branch where you want to insert – cherry-pick – this particular commit. While <code>&lt;live&gt;</code> is the name of this branch, do this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> checkout <span style="color: #000000; font-weight: bold;">&lt;</span>live<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Keep in mind to commit all your changes in the current branch first or stash them.</p>
<p>Lastly you have to tell the checked out branch to use this commit and do the cherry-pick for real!</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> cherry-pick <span style="color: #000000; font-weight: bold;">&lt;</span>hash-partial<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p><code>&lt;hash-partial&gt;</code> is pretty self explaining I guess.</p>
<p>Git now automatically merges the commit into the specific branch.</p>
<h2>Merging Branches Later</h2>
<p>From what I experienced it is no problem to merge branches later when you cherry-picked some commits. This works just fine!</p>
]]></content:encoded>
			<wfw:commentRss>http://drublic.de/blog/about-gits-cherry-picking/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Effects for the Web!</title>
		<link>http://drublic.de/blog/effects-for-the-web/</link>
		<comments>http://drublic.de/blog/effects-for-the-web/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 12:09:06 +0000</pubDate>
		<dc:creator>Christian "Schepp" Schaefer</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Filters]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[SVG]]></category>
		<category><![CDATA[Webkit]]></category>

		<guid isPermaLink="false">http://drublic.de/blog/?p=648</guid>
		<description><![CDATA[Christian &#8220;Schepp&#8221; Schaefer shows how to use the new filter-properties for CSS3 and combine them with methods implemented by most modern browsers. This article was first published in German on December 19th 2011. In the late nineties CSS 2.1 brought us a basic set of good-enough tools to finally get table-free layouts en route. Then came CSS3 which started off by providing us with more creative tools to carve out the details. Today we finally have embeddeable fonts, rounded corners, gradients, semitransparent elements and colors, box and text shadows and so on and so forth. Yet, comparing our toolset with<p><a title="Link toEffects for the Web!" class="more-link" href="http://drublic.de/blog/effects-for-the-web/">Read more</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>Christian &#8220;Schepp&#8221; Schaefer shows how to use the new filter-properties for CSS3 and combine them with methods implemented by most modern browsers. This article was <a href="http://maddesigns.de/css3-filter-1525.html" target="_blank">first published</a> in German on December 19th 2011.</strong></p>
<p><span id="more-648"></span></p>
<p>In the late nineties CSS 2.1 brought us a basic set of good-enough tools to finally get table-free layouts en route. Then came CSS3 which started off by providing us with more creative tools to carve out the details. Today we finally have embeddeable fonts, rounded corners, gradients, semitransparent elements and colors, box and text shadows and so on and so forth.</p>
<p>Yet, comparing our toolset with that of an image editor like Photoshop we still discover a lot to desire. In Photoshop, for example, we have possibilities to desaturate parts of an image, or to sharpen or blur them. How might we need that for the web? Well, desaturating or blurring an area of a web page might be a means of directing your visitor&#8217;s attention to where you want it to be. Or it might help your visitor to concentrate better on an area, which you left untouched. Such a case might be magnifying pictures of a gallery:</p>
<p><a href="http://mikematas.com/#!g9/2nLk/photos/one_week_in_japan_-_3_of_5"><img src="http://drublic.de/blog/wp-content/uploads/2011/12/Mike-Matas-One-Week-In-Japan.png" alt="" width="550" height="237" class="size-full wp-image-672" /></a></p>
<p>A sharpen effect on the other hand might be useful when you scale down images in the browser, since without counter-measures you lose a lot of image details.</p>
<p><a href="http://drublic.de/blog/effects-for-the-web/sharpen/" rel="attachment wp-att-674"><img src="http://drublic.de/blog/wp-content/uploads/2011/12/sharpen.jpg" alt="" width="550" height="489" class="alignnone size-full wp-image-674" /></a></p>
<p>That said, it would be nice if we had such effects and could apply them the same way we do apply <code>opacity</code> to tranparentize a whole area. Alas, we don&#8217;t.</p>
<h2>The status quo</h2>
<p>Instead, to replicate a desaturation/grey scaling we are currently forced to cycle &#8220;by hand&#8221; through the color values of every affected element with JavaScript and set them to a corresponding grey value. When we meet (background-)images or videos it gets even more complicated: Then we need to switch to <a href="http://spyrestudios.com/html5-canvas-image-effects-black-white/" target="_blank">HTML5 canvas to manipulate their color-values pixel by pixel</a> and swap out the original ones. But even if we get help from libraries like <a href="http://camanjs.com/examples" target="_blank">CamanJS</a> or <a href="http://www.iliasiovis.com/hoverizr/" target="_blank">Hoverizr</a>, it remains a profound messy affair.</p>
<p>A blur effect can also be simulated, this time by using <a href="http://webstandard.kulando.de/post/2011/12/09/css3-text-shadow-erzeugt-blur-effekt-tag-10-im-css3-adventskalender-2011" target="_blank">text-shadows</a> and/or <a href="http://tympanus.net/codrops/2011/12/14/item-blur-effect-with-css3-and-jquery/" target="_blank">box-shadows</a> that use the same color/background-color as the to be blurred text/box. The thing is, the illusion doesn&#8217;t work with multicolored boxes and, as before, not with images or video. This requires again some HTML5 canvas action. Sigh.</p>
<p><a href="http://tympanus.net/codrops/2011/12/14/item-blur-effect-with-css3-and-jquery/" target="_blank"><img src="http://drublic.de/blog/wp-content/uploads/2011/12/Item-Blur-Effect-with-CSS3-and-jQuery-Google-Chrome_2011-12-18_11-37-58.png" alt="" width="551" height="443" class="alignnone size-full wp-image-671" /></a></p>
<p>Speaking of HTML5 canvas: A very brutal approach to that blurring topic is being made by a library called <a href="https://github.com/pmura/blurry.js" target="_blank">blurry.js</a>, which extracts all the content, recreates it in a canvas (partially via Cufón), blurs it there and injects the whole thing back to where the original content was.</p>
<p>Finally, for sharpening elements there is no CSS-based trick at all, which leaves us alone with HTML5 canvas.</p>
<h2>SVG to the rescue</h2>
<p>Interestingly SVG knows a huge palette of so-called <a href="http://electricbeach.org/?p=950" target="_blank">filters</a> since ages, e.g. color blending, brightness/contrast adjustments, lighting, displacement mapping, gaussian and motion blur, clouds, noise, sharpen et cetera.</p>
<p>Now, what we might try, since SVG is more and more widely supported, is to not put our content into HTML, but instead to put it into an SVG which we then inline or embed into out HTML &#8220;frame&#8221;. Inside that SVG we are then able to <a href="http://dev.opera.com/articles/view/how-to-do-photoshop-like-effects-in-svg/" target="_blank">apply any effect we like to our contents</a>. The drawback is that a HTMLer won&#8217;t be too keen on switching to SVG markup like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;text</span> <span style="color: #000066;">font-family</span>=<span style="color: #ff0000;">&quot;Arial&quot;</span> <span style="color: #000066;">font-weight</span>=<span style="color: #ff0000;">&quot;900&quot;</span> <span style="color: #000066;">font-size</span>=<span style="color: #ff0000;">&quot;40&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;20&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;55%&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>SVG Example<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Something way cooler is an SVG thing called ForeignObject/xlink, <a href="http://ajaxian.com/archives/foreignobject-hey-youve-got-html-in-my-svg" target="_blank">which allows us to embed foreign objects or areas of foreign markup inside an SVG</a>. Think of it like inlining SVG into an HTML5 document, but the other way &#8217;round. Once you have embedded your stuff, you can apply filters to it like you can for any other area of your SVG. <a href="http://dev.opera.com/articles/view/applying-color-tints-to-web-pages-with-s/" target="_blank">You might embed and filter a full HTML page from A to Z</a>, or you restrict yourself to <a href="http://www.flother.com/examples/canvas-blur/v4/blur.svg" target="_blank">just embedding and filtering a single bitmap image</a>. Of course, you&#8217;d need to put the holding SVG into an HTML page again, which makes up for some Inception-like braintwister (HTML with embedded SVG with embedded HTML). Browser support of the ForeignObject is <a href="http://caniuse.com/#feat=svg-html" target="_blank">quite good</a>. Remains left IE, who will follow suite in version 10 both with SVG filters and ForeignObject.</p>
<h2>SVG Filters in HTML via CSS</h2>
<p>Firefox since version 3.5 goes even further. He allows you to reach out to a filter that resides inside an SVG from out your HTML document&#8217;s stylesheet and have that filter then applied to any HTML element. We could for example define a <code>feGaussianBlur</code>-filter in an SVG with a radius of 2px and assign it the id <code>gaussian_blur</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">standalone</span>=<span style="color: #ff0000;">&quot;no&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #00bbdd;">&lt;!DOCTYPE svg PUBLIC &quot;-//W3C//DTD SVG 1.1//EN&quot; </span>
<span style="color: #00bbdd;">&quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;svg</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.1&quot;</span> </span>
<span style="color: #009900;"><span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2000/svg&quot;</span> </span>
<span style="color: #009900;"><span style="color: #000066;">xmlns:xlink</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/xlink&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;defs<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;gaussian_blur&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;feGaussianBlur</span> <span style="color: #000066;">in</span>=<span style="color: #ff0000;">&quot;SourceGraphic&quot;</span> <span style="color: #000066;">stdDeviation</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/defs<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/svg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Then we could reference that filter by the SVG&#8217;s file name and the filter&#8217;s id in our styles and have it applied to every image:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">img <span style="color: #00AA00;">&#123;</span>
  filter<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span>blur<span style="color: #6666ff;">.svg</span><span style="color: #cc00cc;">#gaussian_blur</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p><a href="http://drublic.de/blog/effects-for-the-web/unscharfe-via-css-filter-svg-mozilla-firefox_2011-12-18_21-18-59/" rel="attachment wp-att-668"><img src="http://drublic.de/blog/wp-content/uploads/2011/12/Unschärfe-via-CSS-Filter-SVG-Mozilla-Firefox_2011-12-18_21-18-59.png" alt="" width="519" height="343" class="alignnone size-full wp-image-668" /></a></p>
<p>You find a live-demo <a href="http://www.der-schepp.de/code-files/blur.html" target="_blank">here</a>. Alas, as I said, this just works with Firefox.</p>
<p>Thankfully this is not the end of the story. IE also knows filters, although not SVG-based, but instead based on early incarnations of the Windows graphics library DirectX. Amongst those filters are not only the well known alpha oder gradient filters that we use to fix bugs or to replicate CSS3 features. There are also filters that are quite similar to many of the interesting SVG filters:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* blur by 2 pixels */</span>
filter<span style="color: #00AA00;">:</span> progid<span style="color: #3333ff;">:DXImageTransform</span><span style="color: #6666ff;">.Microsoft</span>.Blur<span style="color: #00AA00;">&#40;</span>pixelradius<span style="color: #00AA00;">=</span><span style="color: #cc66cc;">2</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #808080; font-style: italic;">/* 13 pixel motion blur rotated to an angle of 310° */</span>
filter<span style="color: #00AA00;">:</span> progid<span style="color: #3333ff;">:DXImageTransform</span><span style="color: #6666ff;">.Microsoft</span>.MotionBlur<span style="color: #00AA00;">&#40;</span>strength<span style="color: #00AA00;">=</span><span style="color: #cc66cc;">13</span><span style="color: #00AA00;">,</span> <span style="color: #000000; font-weight: bold;">direction</span><span style="color: #00AA00;">=</span><span style="color: #cc66cc;">310</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #808080; font-style: italic;">/* grey scale / desaturate */</span>
filter<span style="color: #00AA00;">:</span> <span style="color: #993333;">gray</span><span style="color: #00AA00;">;</span>
<span style="color: #808080; font-style: italic;">/* Röntgen effect (inverted grey scale) */</span>
filter<span style="color: #00AA00;">:</span> xray<span style="color: #00AA00;">;</span>
<span style="color: #808080; font-style: italic;">/* light cone */</span>
filter<span style="color: #00AA00;">:</span> light<span style="color: #00AA00;">&#40;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #808080; font-style: italic;">/* emboss */</span>
filter<span style="color: #00AA00;">:</span> progid<span style="color: #3333ff;">:DXImageTransform</span><span style="color: #6666ff;">.Microsoft</span>.emboss<span style="color: #00AA00;">&#40;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span></pre></div></div>

<p>You find a full list of those visual filters <a href="http://msdn.microsoft.com/en-us/library/ms673539(v=VS.85).aspx" target="_blank">here</a>.</p>
<p>So, with the help of conditional comments we can now already serve certain effects to two browser families, which together make up a considerable amount of the browser market:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE HTML&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!--[if lte IE 9]&gt; &lt;html class=&quot;ie&quot; lang=&quot;en&quot;&gt; &lt;![endif]--&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!--[if gt IE 9]&gt;&lt;!--&gt;</span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> <span style="color: #000066;">lang</span>=<span style="color: #ff0000;">&quot;en&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span> <span style="color: #808080; font-style: italic;">&lt;!--&lt;![endif]--&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;meta</span> <span style="color: #000066;">charset</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Blur via CSS<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
img {
  filter: url(blur.svg#gaussian_blur);
}
.ie img {
  margin: -2px;
  filter: progid:DXImageTransform.Microsoft.blur(pixelradius=2);
  zoom: 1;
}
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;stadt.jpg&quot;</span></span>
<span style="color: #009900;">   <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;Some rights reserved by zigazou76&quot;</span></span>
<span style="color: #009900;">   <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;500&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;333&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><em><code>margin: -2px</code> counters the increased dimensions of the filtered element in IE. <code>zoom: 1</code> is needed for most filters to work in IE6/7. Sad fact: IE10 won&#8217;t support filters anymore :(</em></p>
<p><a href="http://www.der-schepp.de/code-files/blur2.html" target="_blank">Here you find the extended example</a></p>
<p>As people liked Firefox&#8217;s idea to open up SVG filters for use with HTML, those people formed a new task force in the W3C called W3C FX Task Force whose purpose it got to standardize and even simplify usage of SVG filters for use in all browsers. Because Firefox already pioneered filter effects the first draft didn&#8217;t take too long to appear under the label of <a href="https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html" target="_blank">W3C Filter Effects 1.0</a>. The mechanics proposed in that draft work almost like in Firefox, but with the addition of offering shortcuts to some of the most interesting filters. Filters that have a shortcut defined work without the help of an external SVG. They are sort of permanently hard wired inside browser engine. Those are the filters with shortcuts:</p>
<ul>
<li>grayscale</li>
<li>sepia</li>
<li>saturate</li>
<li>hue-rotate</li>
<li>invert</li>
<li>opacity</li>
<li>brightness</li>
<li>contrast</li>
<li>blur</li>
<li>drop-shadow</li>
</ul>
<p>Another advantage of the shortcut filters is that they are animateable via CSS transitions or animations:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.foo</span> <span style="color: #00AA00;">&#123;</span>
  filter<span style="color: #00AA00;">:</span> blur<span style="color: #00AA00;">&#40;</span><span style="color: #933;">2px</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
  transition<span style="color: #00AA00;">:</span> filter 1s ease-in-out<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.foo</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
  filter<span style="color: #00AA00;">:</span> blur<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>This would be much harder and less efficient to do within an SVG.</p>
<p>Finally the filter effects are planned to be extended with <a href="http://www.adobe.com/devnet/html5/articles/css-shaders.html" target="_blank">OpenGL/WebGL vertex and fragment shaders</a>. Vertex shaders will let you span a 2D mesh over an element and then let you distort the object by moving all the crossing points of the mesh following a mathematical formula of your choice. Fragment shaders on the other hand will allow you to do such mathematical processing on the colors of every pixel of that element. And all of it, on top, hardware accelerated on your graphics card.</p>
<p><a href="http://www.adobe.com/devnet/html5/articles/css-shaders.html"><img src="http://drublic.de/blog/wp-content/uploads/2011/12/CSS-shaders-Cinematic-effects-for-the-web-Adobe-Developer-Connection-Google_2011-12-18_19-31-01.png" alt="" width="550" height="304" class="alignnone size-full wp-image-669" /></a></p>
<p>Conveniently last week saw the first implementation of those filters in the <a href="http://nightly.webkit.org/" target="_blank">WebKit-Nightlies</a>, from were they quickly spawned over to <a href="http://tools.google.com/dlpage/chromesxs" target="_blank">Chrome Canary</a>. That means that within a 3 months timeframe CSS filter effects will be available in your everyday Chrome browser and probably not too much later also in Safari. And this means that we are not too far away from being able to serve some flavor of CSS filters to 90% &#8211; 95% of all browsers on the market!</p>
<p>Returning to our code example, all that we need to add for WebKit now is a simple <code>-webkit-filter: blur(2px);</code> which for once we need to put <em>after</em> the unprefixed <code>filter</code>-property. The reason is that once WebKit will support an unprefixed <code>filter</code>-property that Firefox-specific syntax in the last line would kill our CSS transition, which we do apply in order to fade nicely from blurred to unblurred and back via <code>-webkit-transition: -webkit-filter 1s ease-in-out</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE HTML&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!--[if lte IE 9]&gt; &lt;html class=&quot;ie&quot;&gt; &lt;![endif]--&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!--[if gt IE 9]&gt;&lt;!--&gt;</span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #808080; font-style: italic;">&lt;!--&lt;![endif]--&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;meta</span> <span style="color: #000066;">charset</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Blur via CSS<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
img {
  filter: url(blur.svg#gaussian_blur);
  -webkit-filter: blur(2px);
  -webkit-transition: -webkit-filter 1s ease-in-out;
}
img:hover {
  filter: none;
  -webkit-filter: blur(0);
}
.ie img {
  margin: -2px;
  filter: progid:DXImageTransform.Microsoft.blur(pixelradius=2);
  zoom: 1;
}
.ie img:hover {
  margin: 0;
  filter: none;
}
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;stadt.jpg&quot;</span></span>
<span style="color: #009900;">   <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;Some rights reserved by zigazou76&quot;</span></span>
<span style="color: #009900;">   <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;500&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;333&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><a href="http://www.der-schepp.de/code-files/blur3.html" target="_blank">And here is the final example</a>.</p>
<p>And that&#8217;s it, filter effects for everyone! Let 2012 be the year of the CSS filters and <a href="http://davidwalsh.name/dw-content/css-filters.php">have fun playing with&#8217;em</a>.</p>
<section style="clear: both;margin-top: 30px"><img src="http://drublic.de/blog/wp-content/uploads/2011/12/Schepp-2010a-220x240.jpg" alt="" width="110" height="120" class="alignleft size-thumbnail wp-image-673" style="margin-right: 10px" />Christian ”Schepp” Schaefer is a freelance web developer living in Düsseldorf, Germany. He is the author of <a href="http://github.com/Schepp/CSS-JS-Booster">CSS-JS-Booster</a>, co-author of <a href="http://turbinecss.org/">Turbine CSS Framework</a>, one hosts of the (German) <a href="http://workingdraft.de">Working Draft Podcast</a> and he follows your tweets with his account <a href="http://twitter.com/derSchepp">derSchepp</a>.</section>
]]></content:encoded>
			<wfw:commentRss>http://drublic.de/blog/effects-for-the-web/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Is Mothereffin&#8217; jQuery Up?</title>
		<link>http://drublic.de/blog/is-mothereffin-jquery-up/</link>
		<comments>http://drublic.de/blog/is-mothereffin-jquery-up/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 09:23:50 +0000</pubDate>
		<dc:creator>Hans Christian</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[CDN]]></category>
		<category><![CDATA[HTML5 Boilerpate]]></category>
		<category><![CDATA[Mobile First]]></category>
		<category><![CDATA[Mothereffin]]></category>
		<category><![CDATA[Responsive Design]]></category>
		<category><![CDATA[Tool]]></category>

		<guid isPermaLink="false">http://drublic.de/blog/?p=617</guid>
		<description><![CDATA[Some weeks ago I made a pull request for HTML5Boilerplate which should update jQuery to the latest version available on the Google CDN. How ever I copied the old version of minified jQuery because the uncompressed version was available but the minified wasn&#8217;t. Stupid thing! That&#8217;s why I created Is Mothereffin&#8217; jQuery up? The service checks three major CDNs for the availability of the latest jQuery version. View Is Mothereffin&#8217; jQuery up? How to Check if the File is up I had some difficulties to find the right method how to detect if a file is already available with JavaScript.<p><a title="Link toIs Mothereffin' jQuery Up?" class="more-link" href="http://drublic.de/blog/is-mothereffin-jquery-up/">Read more</a></p>]]></description>
			<content:encoded><![CDATA[<p>Some weeks ago I made a <a href="https://github.com/h5bp/html5-boilerplate/pull/852" title="Pull Request to update jQuery to version 1.7.0" target="_blank">pull request for HTML5Boilerplate</a> which should update jQuery to the latest version available on the Google <abbr title="Content Delivery Network">CDN</abbr>. How ever I copied the old version of minified jQuery because the uncompressed version was available but the minified wasn&#8217;t. Stupid thing!</p>
<p>That&#8217;s why I created <a href="http://ismothereffinjqueryup.drublic.de/" title="Visit the project's page and check if the latest jQuery-version is already available on CDNs" target="_blank">Is Mothereffin&#8217; jQuery up?</a> The service checks three major CDNs for the availability of the latest jQuery version.</p>
<p><a href="http://ismothereffinjqueryup.drublic.de/" title="Visit the project's page and check if the latest jQuery-version is already available on CDNs" target="_blank" class="button">View Is Mothereffin&#8217; jQuery up?</a></p>
<h2>How to Check if the File is up</h2>
<p>I had some difficulties to find the right method how to detect if a file is already available with JavaScript. If you don&#8217;t have to deal with cross-domain requests this is not a big thing and done pretty easy. But I need cross-domain requests.</p>
<p>If a file is not available on a server, the request dies with an error 404 and no callback will be called. See <a href="http://jsfiddle.net/drublic/9rgXz/" target="_blank">this Fiddle</a> for a test-case. Even a <code>try-catch</code>-expression <a href="http://jsfiddle.net/drublic/WqWEC/" title="Tested on jsFiddle" target="_blank">does not help</a>.</p>
<p>I decided to check all files for availability and if the request ends up in an error nothing will happen. The script will check if all files are available after three seconds and will otherwise &#8220;tell&#8221; the user that it&#8217;s not. This is not a bullet-proof method as it could take more then three seconds to request all files. If you have a better idea please let me know.<br />
For the moment the resources will be labeled as &#8220;available&#8221; when they are loaded even if they were labeled &#8220;not available&#8221; before. So you will not end up with wrong result, it just may take a second more to show you that.</p>
<h2>The Styles</h2>
<p>The project was build &#8220;mobile-first&#8221;. It makes use of the <a href="http://www.w3.org/TR/css3-flexbox/" title="The specification of the CSS3 Flexible Box Model" target="_blank">CSS3 Flexible Box Model</a> instead of <code>float</code> and all the other stuff.</p>
<p>I&#8217;m not supporting IE in any way because I think most web-developer don&#8217;t use Internet Explorer.</p>
<h2>Todo</h2>
<ul>
<li>Support more libraries such as Mootools, Dojo, Prototype, ExtJS and YUI</li>
<li>Let users submit other CDN via a form</li>
<li><del>Link buttons to their library</del><ins>Done with <a href="https://github.com/drublic/isMothereffinjQueryUp/commit/145a150854bde08ae651f0124b363a4120b7156b" target="_blank">this commit</a></ins> &#8211; <a href="http://drublic.de/blog/is-mothereffin-jquery-up/#comment-166">suggestion</a> by <a href="http://mathiasbynens.be/">Mathias</a></li>
</ul>
<p>Let me know if you want some other features.</p>
<h2>Contribute via GitHub</h2>
<p>I&#8217;ve put this <a href="https://github.com/drublic/isMothereffinjQueryUp" title="The project on GitHub" target="_blank">project up</a> on GutHub. Feel free to contribute or just watch it.</p>
<p>Feature requests can also be placed in <a href="https://github.com/drublic/isMothereffinjQueryUp/issues" title="The issue tracker for isMothereffinjQueryUp" target="_blank">the issue-tracker</a> there.</p>
]]></content:encoded>
			<wfw:commentRss>http://drublic.de/blog/is-mothereffin-jquery-up/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Responsive Media</title>
		<link>http://drublic.de/blog/responsive-media/</link>
		<comments>http://drublic.de/blog/responsive-media/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 21:50:09 +0000</pubDate>
		<dc:creator>Hans Christian</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[bandwidth]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[responsive]]></category>
		<category><![CDATA[Responsive Design]]></category>
		<category><![CDATA[Web-Apps]]></category>

		<guid isPermaLink="false">http://drublic.de/blog/?p=557</guid>
		<description><![CDATA[There is a big discussion going on at the moment covering the actual point of how to deal with images and media et al. on mobile-phones and other devices as there are some things that don&#8217;t work as on a desktop computer: Bandwidth Screen size Performance / Velocity The question is how to deliver responsive images on a mobile website. You maybe use something like img { max-width: 100%; height: auto; } in your responsive design to prevent images from being bigger then the screen of a mobile device. In most of the cases this shrinks images in its displayed<p><a title="Link toResponsive Media" class="more-link" href="http://drublic.de/blog/responsive-media/">Read more</a></p>]]></description>
			<content:encoded><![CDATA[<p>There is a big discussion going on at the moment covering the actual point of how to deal with images and media et al. on mobile-phones and other devices as there are some things that don&#8217;t work as on a desktop computer:</p>
<ul>
<li>Bandwidth</li>
<li>Screen size</li>
<li>Performance / Velocity</li>
</ul>
<p>The question is how to deliver responsive images on a mobile website.</p>
<p>You maybe use something like <code>img { max-width: 100%; height: auto; }</code> in your responsive design to prevent images from being bigger then the screen of a mobile device.</p>
<p>In most of the cases this shrinks images in its displayed size, which is a processor intensive thing to do &#8211; especially when you are on a mobile device and don&#8217;t have endless processor capacity this hurts.<br />
The shrinking itself does not change the file-size that has to be loaded; it remains the same as on a desktop for example. As bandwidth is the bottleneck these days if you are on a mobile device, this is the issue where people want to see some improvement.</p>
<h2>What can we do about it?</h2>
<p>There are a couple of proposals and known techniques on how to solve the problem:</p>
<h3>1. Resize images with PHP</h3>
<p>This is something you could only do if you know the screen-size before you load the images them self. So you have to inject HTML through JavaScript for example and change the sources for images accordingly.</p>
<p>The <a href="http://adaptive-images.com/" target="_blank">Adaptive Images</a> framework a similar technique. Check out the <a title="Adaptive Images on GitHub" href="https://github.com/MattWilcox/Adaptive-Images" target="_blank">source on GitHub</a>.</p>
<h3>2. Request different images using data-attributes</h3>
<p>An article by Nicolas Gallagher covers this method using CSS to detect which source would be best to use.</p>
<p>The method could work like this: You have an image which has a really small file size and is served for every device at first (mobile first approche).</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;image.jpg&quot;</span> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">data-src-600px</span>=<span style="color: #ff0000;">&quot;image-600px.jpg&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>Now you are going to change the file if the screen is bigger by using the <code>content</code>-property of CSS and its <code>attr()</code> function.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@media (min-device-width:600px) {</span>
    img<span style="color: #00AA00;">&#91;</span>data-src<span style="color: #933;">-600px</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">content</span><span style="color: #00AA00;">:</span> attr<span style="color: #00AA00;">&#40;</span>data-src<span style="color: #933;">-600px</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
    <span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Please have a look <a title="Responsive images using CSS3" href="http://nicolasgallagher.com/responsive-images-using-css3/" target="_blank">at the article</a> for detailed information.</p>
<p>An idea that goes beyond the replacement of images with the <code>attr()</code>-function is the usage of <code>content: url(myimage.jpg) replaced;</code>. This is something <a title="Tab Atkins' suggestion to use replaced content" href="http://lists.w3.org/Archives/Public/www-style/2011Aug/0661.html" target="_blank">suggested</a> by Tab Atkins Jr. on the W3C www-styles mailing list &#8211; called replaced content.<br />
Something about <a title="Replaced Content in the CSS-specification" href="http://www.w3.org/TR/css3-content/#replacedContent" target="_blank">replaced content</a> appears in the CSS-spec but it does not look to be exactly what Tab is referring to.</p>
<h3>3. Introduce new attributes to the &lt;img&gt;-tag</h3>
<p><a title="Anselm's website" href="http://anselm.novolo.de/">Anselm Hannemann</a> <a title="Anselm's idea on the WHATWG's Mailing list" href="http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-August/032977.html">shares the idea</a> of introducing a media-attribute that has some sort of &#8220;sizing-parameter&#8221;. It is supposed to be combined with the media-src-attribute which also has the sizing-parameter.<br />
The HTML could look something <a title="Gist by Anselm dealing with media- and media-src-attribute" href="https://gist.github.com/1158855" target="_blank">like this</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;myimage_xs.jpg&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">media-xs</span>=<span style="color: #ff0000;">&quot;(min-device-width:320px and max-device-width:640px)&quot;</span> <span style="color: #000066;">media-src-xs</span>=<span style="color: #ff0000;">&quot;myimage_xs.jpg&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">media-m</span>=<span style="color: #ff0000;">&quot;(min-device-width:640px and max-device-width:1024px)&quot;</span> <span style="color: #000066;">media-src-m</span>=<span style="color: #ff0000;">&quot;myimage_m.jpg&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">media-xl</span>=<span style="color: #ff0000;">&quot;(min-device-width:1024px)&quot;</span> <span style="color: #000066;">media-src-xl</span>=<span style="color: #ff0000;">&quot;myimage_xsl.jpg&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<p>As you can see the <code>media</code>-attributes contain media-queries which describe when to take a certain image-source.</p>
<h3>4. Using JavaScript</h3>
<p>There are some ideas on how to deal with this topic using JavaScript.</p>
<p>The FilamentGroup for example published its &#8220;Responsive Images&#8221;-project <a title="An Experiment with Mobile-First Images that Scale Responsively &amp; Responsibly" href="https://github.com/filamentgroup/Responsive-Images" target="_blank">on GitHub</a>. They are using &#8220;Mobile-First&#8221; to present a small-sized image on every device and replace this with JavaScript on window load.<br />
You can find out more about how it works <a title="_blank" href="http://filamentgroup.com/lab/responsive_images_experimenting_with_context_aware_image_sizing/">on their blog</a>. They also published <a title="Demo of Responsive Images" href="http://filamentgroup.com/examples/responsive-images/" target="_blank">a demo</a>.</p>
<p>Peter-Paul Koch <a title="Combining media queries and JavaScript" href="http://www.quirksmode.org/blog/archives/2010/08/combining_media.html" target="_blank">presented a possible way</a> on how to combine media queries with JavaScript. Which is not really new I think but a good summery.</p>
<p>Another approach could be a new attribute for the <code>script</code>-tag: Scott Jehl <a title="Scott Jehl's suggestion on responsive images: a `preparse`-attribute for the `script`-tag" href="https://twitter.com/#!/scottjehl/status/119836986101075968">suggested</a> to call it <code>preparse</code>. The script could then be used to replace sources in HTML fitting the current client-need.</p>
<p><img class="aligncenter" title="Bildschirmfoto 2011-11-16 um 00.04.34" src="http://drublic.de/blog/wp-content/uploads/2011/11/Bildschirmfoto-2011-11-16-um-00.04.34.png" alt="" width="654" height="263" /></p>
<h3>5. A new image-format containing different sizes</h3>
<p>People aso had the idea of creating an own image-format which contains for example four layers with different image sizes. The image then &#8220;decides&#8221; which format to take and serves this to the client without its three sibling-layers.</p>
<p>At the moment there is a format called <a title="MrSID on Wikipedia" href="http://en.wikipedia.org/wiki/MrSID" target="_blank">MrSID</a> developed by <a title="LizardTech on Wikipedia" href="http://en.wikipedia.org/wiki/LizardTech">LizardTech</a> which can have one or more compression rates.</p>
<p>Another approach is the <a title="JPEG 2000 on Wikipedia" href="http://en.wikipedia.org/wiki/JPEG_2000">JPEG 2000</a> file-format. It can carry out different optimization-levels for images. Read more about it on the Wikipedia-page I linked above.</p>
<h2>Media? But this was only about images…</h2>
<p>Yup, right! Images are just one aspect when it comes to responsive media.<br />
Videos for example are another thing. YouTube offers different video-sizes for watching. You have to choose manually which one to use. A possibility to select this resource automatically, build into the browser would be awesome!</p>
<p>JPEG 2000 has a video-equivalent developed by the same group of people as the JPEG-format called Motion JPEG 2000. Find more information about this <a href="http://www.jpeg.org/jpeg2000/j2kpart3.html" title="Motion JPEG 2000" target="_blank">here</a>.</p>
<h2>Conclusion</h2>
<p>As it turns out many developers are not aware of the problems that come up with a real responsive design &#8211; even HTML5-specification writer are <a title="Anne van Kersten calls responsive media 'a niche problem' on the W3C mailing-list" href="http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-August/033029.html">calling it</a> &#8220;a niche problem&#8221;. This is why it is hard to develop a specification for a native API as for example Anselm Hannemann suggests.</p>
<p>But maybe the decision which technique might be best for solving the problem of serving responsive media has to be finished first before anything is spec&#8217;d up.</p>
<h2>Moar!</h2>
<p>Some more resources where the topic is discussed:</p>
<ul>
<li>A List Apart started the whole “Responsive Design”-discussion with <a href="http://www.alistapart.com/articles/responsive-web-design" title="Responsive Web Design" target="_blank">an article</a> by Ethan Marcotte</li>
<li><a href="https://groups.google.com/forum/#!topic/jquery-standards/rl8886ZRs8o" title="Responsive images discussed by the jQuery Standards Team - Google Group" target="_blank">jQuery Standards Team</a></li>
<li><a href="http://www.webmonkey.com/2011/08/speed-up-your-responsive-designs-with-adaptive-images/" title="Scott Gilbertson - Webmonkey - about responsive images">Scott Gilbertson on Webmonkey</a></li>
<li><a href="http://csswizardry.com/2011/07/responsive-images-right-now/" title="Responsive images right now" target="_blank">Another CSS-only idea</a> by Harry Roberts</li>
</ul>
<h3>Thanks!</h3>
<p>Thanks goes out to <a title="Anselm on Twitter" href="https://twitter.com/anselmhannemann" target="_blank">Anselm</a>, for reading what I wrote and helping me with some further information.</p>
]]></content:encoded>
			<wfw:commentRss>http://drublic.de/blog/responsive-media/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

