<?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>Ruslan Ulanov's Codeshack &#187; CSS</title>
	<atom:link href="http://ulanoff.com/blogs/codeshack/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://ulanoff.com/blogs/codeshack</link>
	<description>The developer's notebook</description>
	<lastBuildDate>Tue, 29 Sep 2009 00:33:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>data Protocol &#8211; embed your data</title>
		<link>http://ulanoff.com/blogs/codeshack/2009/07/08/data-protocol-embed-your-data/</link>
		<comments>http://ulanoff.com/blogs/codeshack/2009/07/08/data-protocol-embed-your-data/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 22:31:26 +0000</pubDate>
		<dc:creator>Ruslan Ulanov</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[ie8]]></category>

		<guid isPermaLink="false">http://ulanoff.com/blogs/codeshack/?p=37</guid>
		<description><![CDATA[Recently, looking for a completely unrelated subject I discovered that IE8 now supports the data protocol. What is a data protocol? In a few words, it&#8217;s a way to embed any data (like GIF images, for example) into text documents such as HTML or CSS. So, instead of linking to an external file, you can do something [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, looking for a completely unrelated subject I discovered that IE8 now supports the <em>data</em> protocol.</p>
<h3>What is a data protocol?</h3>
<p>In a few words, it&#8217;s a way to embed any data (like GIF images, for example) into text documents such as HTML or CSS. So, instead of linking to an external file, you can do something like this:</p>
<h4>HTML</h4>
<p>[html]&lt;IMG<br />
SRC=&#8217;data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAA wAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfz gFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiO Spa/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZ eGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81  M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7&#8242;<br />
ALT=&#8217;Larry&#8217;&gt;[/html]</p>
<p><span id="more-37"></span>The data protocol is not something new, it is dated all the way back to 1995, when it was proposed. And in 1998 it became known as RFC2397.</p>
<p>The following elements and/or attributes could make a use of the <em>data</em> protocol:</p>
<ul>
<li>object (images only)</li>
<li>img</li>
<li>input type=image</li>
<li>link</li>
<li>CSS declarations that accept a URL, such as background, backgroundImage, and so on.</li>
</ul>
<p>Let&#8217;s look at some examples:</p>
<h4>CSS</h4>
<p>[css].img { background: url(data:image/png;base64,iVBORw0KGgoAAAANSU hEUgAAAAIAAAACCAIAAAD91JpzAAAABnRSTlMAAAAAAABupgeRAAAABmJLR0QA%2FwD %2FAP%2BgvaeTAAAAEUlEQVR42mP4%2F58BCv7%2FZwAAHfAD%2FabwPj4AAAAASUVO RK5CYII%3D) fixed 1px 0; }[/css]</p>
<h4>JS</h4>
<p>[javascript]var img = new Image();<br />
img.style.width = &#8217;100px&#8217;;<br />
img.style.height = &#8217;100px&#8217;;<br />
img.src = &#8216;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCA IAAAD91JpzAAAABnRSTlMAAAAAAABupgeRAAAABmJLR0QA%2FwD%2FAP%2BgvaeTAAA AEUlEQVR42mP4%2F58BCv7%2FZwAAHfAD%2FabwPj4AAAAASUVORK5CYII%3D&#8217;;<br />
document.all.myBody.appendChild(img);[/javascript]</p>
<h3>Why would you want to use a data protocol?</h3>
<p>The most obvious reason could be the portability.</p>
<p>You might be familiar with the <a href="https://addons.mozilla.org/en-US/firefox/addon/748">Greasemonkey</a> add-on to Firefox and some other browsers. It allows you to write small bits of JavaScript to customize web pages with new features or change the look of the entire site alltogether. For example, you could write a script to add &#8220;Download&#8221; button to every movie on YouTube site. To make this button look like it &#8220;was there&#8221; you could create a little image and apply it to the button with a style. That image could be embedded in your JS file with a <em>data</em> protocol. This way you wouldn&#8217;t have to worry about packaging all your files in a ZIP archive and unpackaging them in the right location on the target system. All you have to download is a single JS file. Great, isn&#8217;t it?</p>
<h3>P.S.</h3>
<p>Please note that there are some limitations to keep in mind when dealing with <em>data</em> protocol. First, RFC1866 limits lengths of some attributes to 1024 characters, so if base64 encoded string is too long the object might appear broken in the browser. Second, to be on a safe side try to keep the entire base64 string on one line. Splitting it with line break/carriage return characters might break the data.</p>
<p>Also, most modern browsers (such as Firefox, Safari and Chrome) would support <em>data</em> protocol, but IE7 and older will not, so you might want to provide some alternative for the older browsers.</p>
<p>For more information visit the following sites:</p>
<ul>
<li>IETF: <a href="http://www.ietf.org/rfc/rfc2397.txt">RFC2397 &#8211; The &#8220;data&#8221; URL scheme</a>,</li>
<li>IETF: <a href="http://www.ietf.org/rfc/rfc1866.txt">RFC1866 &#8211; Hypertext Markup Language &#8211; 2.0</a></li>
<li>MSDN: <a href="http://msdn.microsoft.com/en-us/library/cc848897%28VS.85%29.aspx">data Protocol</a></li>
<li>Motobit: <a href="http://www.motobit.com/util/base64-decoder-encoder.asp">online base64 encoder/decoder</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://ulanoff.com/blogs/codeshack/2009/07/08/data-protocol-embed-your-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mobile Web Best Practices 1.0</title>
		<link>http://ulanoff.com/blogs/codeshack/2008/08/07/mobile-web-best-practices-10/</link>
		<comments>http://ulanoff.com/blogs/codeshack/2008/08/07/mobile-web-best-practices-10/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 19:30:40 +0000</pubDate>
		<dc:creator>Ruslan Ulanov</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://ulanoff.com/blogs/codeshack/?p=12</guid>
		<description><![CDATA[The World Wide Web Consortium (W3C) has recently published a document called Mobile Web Best Practices 1.0. This document specifies Best Practices for delivering Web content to mobile devices. The principal objective is to improve the user experience of the Web when accessed from such devices. It&#8217;s a good step toward making the Web accessible [...]]]></description>
			<content:encoded><![CDATA[<p>The World Wide Web Consortium (W3C) has recently published a document called <em>Mobile Web Best Practices 1.0</em>.</p>
<blockquote><p>This document specifies Best Practices for delivering Web content to mobile devices. The principal objective is to improve the user experience of the Web when accessed from such devices.</p></blockquote>
<p>It&#8217;s a good step toward making the Web accessible to millions of small screen devices, not blessed with a combination of iPhone&#8217;s hi-res LCD and a powerful Safari browser. <img src='http://ulanoff.com/blogs/codeshack/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The document is available from W3C&#8217;s web site <a href="http://www.w3.org/TR/2008/REC-mobile-bp-20080729/">http://www.w3.org/TR/2008/REC-mobile-bp-20080729/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ulanoff.com/blogs/codeshack/2008/08/07/mobile-web-best-practices-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing IE6/IE7 style issues</title>
		<link>http://ulanoff.com/blogs/codeshack/2008/05/27/fixing-ie6ie7-style-issues/</link>
		<comments>http://ulanoff.com/blogs/codeshack/2008/05/27/fixing-ie6ie7-style-issues/#comments</comments>
		<pubDate>Wed, 28 May 2008 00:40:22 +0000</pubDate>
		<dc:creator>Ruslan Ulanov</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://ulanoff.com/blogs/codeshack/2008/05/27/fixing-ie6ie7-style-issues/</guid>
		<description><![CDATA[Check out Cascading Style Sheet Compatibility in Internet Explorer 7 article at MSDN. It explains how to address IE7 compatibility issues in CSS. In short, there were several bugs in CSS parser of IE6. Some CSS constructs (filters) that were applied by IE6 are ignored by IE7 and above &#8211; like &#8220;* html&#8221;. We could take [...]]]></description>
			<content:encoded><![CDATA[<p>Check out <a href="http://msdn.microsoft.com/en-us/library/bb250496(VS.85).aspx">Cascading Style Sheet Compatibility in Internet Explorer 7</a> article at MSDN.</p>
<p>It explains how to address IE7 compatibility issues in CSS.<br />
In short, there were several bugs in CSS parser of IE6. Some CSS constructs (filters) that were applied by IE6 are ignored by IE7 and above &#8211; like &#8220;* html&#8221;. We could take advantage of these broken filters to create IE6-specific rules.</p>
<p><span id="more-8"></span></p>
<p>For example, first define a style that will look fine in IE7:</p>
<p><em>[css]#box { top: 2px; }[/css]</p>
<p></em></p>
<p>then (below that rule in CSS file) use CSS filter &#8220;* html&#8221; to override it with IE6 style:</p>
<p><em>[css]* html #box { top: 4px; }[/css]</p>
<p></em></p>
<p>This second rule will be ignored by IE7 and above, but will fix the problematic style in IE6.</p>
<p>There&#8217;s another approach to fixing IE6/IE7 issues &#8211; it&#8217;s <em>conditional comments</em>.</p>
<p>Consider the following code that should be placed in the HEAD section of HTML:</p>
<p><em>[html]&lt;!&#8211;[if IE 6]&gt;<br />
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/css/ie6.css&quot; /&gt;<br />
&lt;![endif]&#8211;&gt;[/html]</p>
<p></em></p>
<p>The <em>&lt;!&#8211;[if IE 6]&gt;</em> and <em>&lt;![endif]&#8211;&gt;</em> tags are used to filter out content that will be parsed by IE6 browser only, any other browser will ignore anything that&#8217;s inside these tags.</p>
<p>For more info see <a href="http://msdn.microsoft.com/en-us/library/ms537512.aspx" target="_blank">About Conditional Comments</a> on MSDN or more user-friendlier explanation at  <a href="http://www.quirksmode.org/css/condcom.html" target="_blank">Quirksmode</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ulanoff.com/blogs/codeshack/2008/05/27/fixing-ie6ie7-style-issues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IRT.org Knowledge Base</title>
		<link>http://ulanoff.com/blogs/codeshack/2008/05/05/irtorg-knowledge-base/</link>
		<comments>http://ulanoff.com/blogs/codeshack/2008/05/05/irtorg-knowledge-base/#comments</comments>
		<pubDate>Tue, 06 May 2008 00:07:28 +0000</pubDate>
		<dc:creator>Ruslan Ulanov</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://ulanoff.com/blogs/codeshack/2008/05/05/irtorg-knowledge-base/</guid>
		<description><![CDATA[IRT.org has a nice collection of FAQs on DHTML, JS, Java, CSS, etc. http://www.irt.org/faq.htm]]></description>
			<content:encoded><![CDATA[<p>IRT.org has a nice collection of FAQs on DHTML, JS, Java, CSS, etc.</p>
<p><a href="http://www.irt.org/faq.htm">http://www.irt.org/faq.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ulanoff.com/blogs/codeshack/2008/05/05/irtorg-knowledge-base/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use CSS to create an image map</title>
		<link>http://ulanoff.com/blogs/codeshack/2008/04/29/use-css-to-create-an-image-map/</link>
		<comments>http://ulanoff.com/blogs/codeshack/2008/04/29/use-css-to-create-an-image-map/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 01:37:10 +0000</pubDate>
		<dc:creator>Ruslan Ulanov</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://ulanoff.com/blogs/codeshack/2008/04/29/use-css-to-create-an-image-map/</guid>
		<description><![CDATA[TechRepublic.com has an article on using CSS to create an image map. Nice and simple technique though it won&#8217;t work if you need to define complex shapes (like state boundaries on the map of USA, etc.).]]></description>
			<content:encoded><![CDATA[<p>TechRepublic.com has <a href="http://blogs.techrepublic.com.com/programming-and-development/?p=660&amp;tag=nl.e055">an article on using CSS to create an image map</a>. Nice and simple technique though it won&#8217;t work if you need to define complex shapes (like state boundaries on the map of USA, etc.).</p>
]]></content:encoded>
			<wfw:commentRss>http://ulanoff.com/blogs/codeshack/2008/04/29/use-css-to-create-an-image-map/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
