<?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>The Bright Lines &#187; CSS3</title>
	<atom:link href="http://www.thebrightlines.com/tag/css3/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thebrightlines.com</link>
	<description>HTML, CSS, Javascript and more</description>
	<lastBuildDate>Thu, 29 Jul 2010 22:44:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Implementing font-face cross domain</title>
		<link>http://www.thebrightlines.com/2010/01/12/implementing-font-face-cross-domain/</link>
		<comments>http://www.thebrightlines.com/2010/01/12/implementing-font-face-cross-domain/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 21:13:59 +0000</pubDate>
		<dc:creator>Wouter Bos</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Webfonts]]></category>
		<category><![CDATA[cross-domain]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[EOT]]></category>
		<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://www.thebrightlines.com/?p=363</guid>
		<description><![CDATA[Firefox is fussy about fonts residing on other domains.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m still in the middle of a redesign of my <a href="http://electricspace.blogspot.com/">personal weblog</a>, but I&#8217;m glad I got the font-face working. It was a hard nut to crack. The source of all the trouble was that Firefox would load font files from other domains. Although the domain restriction isn&#8217;t making things easier, it is sort of sensible.</p>
<p>Internet Explorer is the only browser that supports EOT, a font format that has digital rights management. That way you can make sure that your $200 font isn&#8217;t downloaded and used by everybody on the internet.</p>
<p>But like I said: IE is the only browser that can understand that file type. So Mozilla apparently implemented some sort of protection against font hijackers: It will only accept fonts from domains that specifically allow fonts to be downloaded. In case of Apache you have to add the following code below to the .htaccess file. I found it on <a href="http://openfontlibrary.org/wiki/Web_Font_linking_and_Cross-Origin_Resource_Sharing">Open Font Library</a>.</p>
<p><code>&lt;FilesMatch "\.(ttf|otf|eot)$"&gt;<br />
&lt;IfModule mod_headers.c&gt;<br />
Header set Access-Control-Allow-Origin "*"<br />
&lt;/IfModule&gt;<br />
&lt;/FilesMatch&gt;</code></p>
<p>This does not help you prevent people from stealing your font, but it will protect you from web developers who want to add the URL to the font on your domain in their font-face declaration. It&#8217;s not really a solution if you ask me. It seems more like a <em>gesture</em> to the creators of fonts.</p>
<p>It appears you could replace the asteriks with the domain of your website, but in my case (http://electricspace.blogspot.com/) did not do the job.</p>


<p>Related posts:<ol><li><a href='http://www.thebrightlines.com/2009/11/01/the-trouble-with-font-face/' rel='bookmark' title='Permanent Link: The trouble with @font-face'>The trouble with @font-face</a></li>
<li><a href='http://www.thebrightlines.com/2009/11/07/no-sign-of-font-face-in-chrome-4/' rel='bookmark' title='Permanent Link: No sign of @font-face in Chrome 4'>No sign of @font-face in Chrome 4</a></li>
<li><a href='http://www.thebrightlines.com/2009/12/10/251/' rel='bookmark' title='Permanent Link: My favorite for converting fonts to EOT'>My favorite for converting fonts to EOT</a></li>
<li><a href='http://www.thebrightlines.com/2010/01/20/webfont-pitfalls/' rel='bookmark' title='Permanent Link: Webfont pitfalls'>Webfont pitfalls</a></li>
<li><a href='http://www.thebrightlines.com/2010/03/09/new-web-font-service-ascender-corporation/' rel='bookmark' title='Permanent Link: New web font service: Ascenderfonts.com'>New web font service: Ascenderfonts.com</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.thebrightlines.com/2010/01/12/implementing-font-face-cross-domain/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Too advanced CSS selectors</title>
		<link>http://www.thebrightlines.com/2009/12/24/too-advanced-css-selectors/</link>
		<comments>http://www.thebrightlines.com/2009/12/24/too-advanced-css-selectors/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 22:27:05 +0000</pubDate>
		<dc:creator>Wouter Bos</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[selector]]></category>

		<guid isPermaLink="false">http://www.thebrightlines.com/?p=273</guid>
		<description><![CDATA[CSS offers lots of different selectors, but sometimes it's better not to use them.]]></description>
			<content:encoded><![CDATA[<p>A few years ago the only reasonable way to select an element through CSS was by using classes and/or tag names. If you wanted to target a specific element, you had to select it by using its classname. Selecting elements with tag names wasn&#8217;t always practicle. For example: if you use the selector <code>div.container div</code>, you style all <code>div</code> elements inside the <code>div.container</code>.</p>
<p>Most of the time that&#8217;s not what you want. Using tag names as selectors can also make design changes troublesome if you have to add more <code>div</code>s and need to give it a different styling. But since IE7 we can use new selectors that help us to build much more delicate CSS selectors. Those new selectors are:</p>
<ul>
<li>Child selector: <code>.parent &gt; .child</code></li>
<li>First child selector: <code>.parent .child:first-child</code></li>
<li>Adjacent selector: <code>.sibling + .sibling</code></li>
<li>First child selector: <code>div:first-child</code></li>
<li>Attribute selectors: <code>div[id]</code></li>
</ul>
<p>Now you can style the following HTML with just a single class:</p>
<h3>HTML:</h3>
<pre name="code" class="xhtml:nogutter">
<div class='container'>
	<span>This is some title</span>
	<a href="#">Lorem ipsum</a>
	<a href="#">Lorem ipsum</a>
	<a href="#">Lorem ipsum</a>
	<span>Some body text with lots of <span>lorem <span>ipsums</span></span> in it</span>
	<span>Some body text with lots of <span>lorem <span>ipsums</span></span> in it</span>
	<a href="#">Lorem ipsum</a>
</div>
</pre>
<h3>CSS:</h3>
<pre name="code" class="css:nogutter">
.container span {
	font-family: sans-serif;
}
.container > span:first-child {
	font-size: 1.5em;
	font-weight: bold;
	font-family: serif;
}
.container > span > span {
	font-style: italic;
}
.container > span > span > span {
	font-weight: bold;
}
.container > span + span {
	display: block;
	margin-top: 0.5em;
}
.container a:nth-child(2) {
	font-weight: bold;
}
.container a {
	display: block;
	color: #f0f;
}
.container a:nth-child(4) ~ a {
	font-size: 0.9em;
}
</pre>
<p>The advantage is that you can, as you can see, style whole blocks of HTML code with just one class. In theory you could even use no classes at all. Without &#8216;class&#8217;-attributes on every element, the HTML code looks just a little bit more cleaner and readable. You can also use those and other selectors in javascript libraries like jQuery to select particular HTML elements. Since most libraries are cross-browser you don&#8217;t have to worry if a selector is or isn&#8217;t supported by a browser. Consider this piece of code in jQuery:</p>
<pre name="code" class="javascript:nogutter">
jQuery(".container a:nth-child(4) ~ a").click( function() {
	alert('hello world');
})
</pre>
<h2>That&#8217;s all nice, but should I use it?</h2>
<p>No. I use them some times, but I try to stay away from it if possible. The problem with these selectors is that they rely so much on the structure of the HTML that it becomes harder to change the HTML structure. If you take another look at the HTML and CSS that I showed as an example in the beginning of the article, it&#8217;s clear that you can&#8217;t add a few links or spans without having to change the CSS. Add some advanced jQuery selectors in the mix and you may have locked the HTML structure forever since no-one dares to change it.</p>
<h2>Should I discard those new selectors then?</h2>
<p>Not necessarily. Sometimes you just have no choice if you for some reason are not able to change the HTML. My personal guideline is that styling has to be predictable. So when you edit some piece of HTML code, the styling should behave as expected. That means that you don&#8217;t style your HTML in a way that the text-color of the 4th <code>span</code> is red.</p>
<p>So what can be styled predictable? If you ask me advanced selectors shine when the structure is relatively fixed. Lists are a good example. Just take a look at these code blocks below. The styling will behave normal, regardless what you do with the HTML.</p>
<h3>HTML:</h3>
<pre name="code" class="xhtml:nogutter">
<ul class="list">
<li>Lorem</li>
<li>Ipsum</li>
<li>Dolor
<ul>
<li>Sit</li>
<li>Amet</li>
</ul>
</ul>
</pre>
<h3>CSS:</h3>
<pre name="code" class="css:nogutter">
ul.list li + li {
	margin-top: 10px; /* adds top margin to all list items except the first */
}
ul.list > li {
	font-weight: bold; /* styles only the first level list items differently */
}
</pre>
<h3>Javascript:</h3>
<pre name="code" class="javascript:nogutter">
jQuery("ul.list li:nth-child(even)").addClass("zebra"); // adds zebra striping to a list
</pre>
<h2>HTML elements you can easily apply advanced selectors</h2>
<p>Besides <code>ul</code>, you can style <code>ul</code>s, <code>dl</code>s, <code>table</code>s. That doesn&#8217;t mean that other elements should only be styled with classes. There are always some exceptions to the rule. Just let your common sense be the judge.</p>


<p>Related posts:<ol><li><a href='http://www.thebrightlines.com/2009/11/08/how-to-overcome-the-limits-of-css-in-internet-explorer-6/' rel='bookmark' title='Permanent Link: How to overcome the limits of CSS in Internet Explorer 6'>How to overcome the limits of CSS in Internet Explorer 6</a></li>
<li><a href='http://www.thebrightlines.com/2009/10/28/for-the-sloppy-clickers/' rel='bookmark' title='Permanent Link: For the sloppy clickers'>For the sloppy clickers</a></li>
<li><a href='http://www.thebrightlines.com/2010/01/04/alternative-for-nth-of-type-and-nth-child/' rel='bookmark' title='Permanent Link: Alternative for :nth-of-type() and :nth-child()'>Alternative for :nth-of-type() and :nth-child()</a></li>
<li><a href='http://www.thebrightlines.com/2010/01/31/hack-how-to-enable-first-child-in-ie6/' rel='bookmark' title='Permanent Link: Hack: how to enable :first-child in IE6'>Hack: how to enable :first-child in IE6</a></li>
<li><a href='http://www.thebrightlines.com/2009/11/27/filtering-ie6-and-ie7-in-quirks-mode/' rel='bookmark' title='Permanent Link: What you can&#8217;t do in IE&#8217;s Quirks Mode'>What you can&#8217;t do in IE&#8217;s Quirks Mode</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.thebrightlines.com/2009/12/24/too-advanced-css-selectors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My favorite for converting fonts to EOT</title>
		<link>http://www.thebrightlines.com/2009/12/10/251/</link>
		<comments>http://www.thebrightlines.com/2009/12/10/251/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 06:39:33 +0000</pubDate>
		<dc:creator>Wouter Bos</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Webfonts]]></category>
		<category><![CDATA[Convert]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[EOT]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[Fontsquirrel]]></category>
		<category><![CDATA[services]]></category>

		<guid isPermaLink="false">http://www.thebrightlines.com/?p=251</guid>
		<description><![CDATA[Webfonts are fun, but converting fonts to EOT can be a drag. But I found a good conversion service from Fontsquirrel]]></description>
			<content:encoded><![CDATA[<h2>ttf2eot</h2>
<p>In order to use webfonts in your website you have to convert regular fonts to Microsofts EOT format. Normally I would use the online version of ttf2eot, which works reasonably well. As long if you have a TTF. If you have another type of font like a OTF, you have to find another converter first.</p>
<h2>WEFT</h2>
<p>In case ttf2eot fails with a particular font (like in my case) I grudgingly use Microsofts WEFT tool. I dislike WEFT for its instability and weird workflow/interface. But last time I tried it, it didn&#8217;t do a good job at all. Only 3 of the 4 fonts I had to convert to EOT were recognized and none of that 3 fonts worked in IE.</p>
<h2>Fontsquirrel</h2>
<p>Then while looking for a manual on WEFT, I came across the free <a href="http://www.fontsquirrel.com/fontface/generator">@font-face Kit Generator</a> of Fontsquirrel. And man, did <em>that</em> save the day. Uploading and converting the fonts was very easy. On top of it, you get an example web page packed in a zip with the webfonts in it. It looks something like the screenshot below. The service can also convert fonts to <strong>WOFF</strong> (Firefox) and <strong>SVG</strong> (Chrome &amp; iPhone).</p>
<div class="wp-caption alignnone" style="width: 585px"><img title="Fontsquirrel not only converts your fonts to EOT, but also shows an example how it would look like in your browser in various font sizes." src="/article-data/images/Fontsquirrel.png" alt="Fontsquirrel not only converts your fonts to EOT, but also shows an example how it would look like in your browser in various font sizes." width="575" height="167" /><p class="wp-caption-text">Fontsquirrel not only converts your fonts to EOT, but also shows an example how it would look like in your browser in various font sizes.</p></div>
<h2>What to look out for in Fontsquirrel</h2>
<p>The only thing that did go wrong was the hinting. If I chose the default option “Use existing hints” the letter “B” did not render well as you can see in the screenshot below. When I chose to remove the hinting, the conversion was successful.</p>
<div class="wp-caption alignnone" style="width: 213px"><img title="Fontsquirrel too can get it wrong. Always check all the types" src="/article-data/images/Fontsquirrel2.png" alt="Fontsquirrel too can get it wrong. Always check all the types" width="203" height="167" /><p class="wp-caption-text">Fontsquirrel too can get it wrong. Always check all the types</p></div>
<div class="wp-caption alignnone" style="width: 307px"><img title="The problem in the previous piccture was cleard by removing all hints." src="/article-data/images/Fontsquirrel3.png" alt="The problem in the previous piccture was cleard by removing all hints." width="297" height="101" /><p class="wp-caption-text">The problem in the previous piccture was cleard by removing all hints.</p></div>


<p>Related posts:<ol><li><a href='http://www.thebrightlines.com/2009/11/01/the-trouble-with-font-face/' rel='bookmark' title='Permanent Link: The trouble with @font-face'>The trouble with @font-face</a></li>
<li><a href='http://www.thebrightlines.com/2010/01/24/test-popular-professional-fonts-as-webfont/' rel='bookmark' title='Permanent Link: Test: Popular professional fonts as webfont'>Test: Popular professional fonts as webfont</a></li>
<li><a href='http://www.thebrightlines.com/2010/02/28/web-fonts-services-list/' rel='bookmark' title='Permanent Link: List of web fonts services and resources'>List of web fonts services and resources</a></li>
<li><a href='http://www.thebrightlines.com/2010/04/18/interview-with-ethan-dunham-of-fontsquirrel-and-fontspring/' rel='bookmark' title='Permanent Link: Interview with Ethan Dunham of Fontsquirrel and Fontspring'>Interview with Ethan Dunham of Fontsquirrel and Fontspring</a></li>
<li><a href='http://www.thebrightlines.com/2010/01/20/webfont-pitfalls/' rel='bookmark' title='Permanent Link: Webfont pitfalls'>Webfont pitfalls</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.thebrightlines.com/2009/12/10/251/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cool cross-browser styling with CSS and IE&#8217;s filter</title>
		<link>http://www.thebrightlines.com/2009/12/03/using-ies-filter-in-a-cross-browser-way/</link>
		<comments>http://www.thebrightlines.com/2009/12/03/using-ies-filter-in-a-cross-browser-way/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 20:35:22 +0000</pubDate>
		<dc:creator>Wouter Bos</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[cross-browser]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[IE]]></category>

		<guid isPermaLink="false">http://www.thebrightlines.com/?p=174</guid>
		<description><![CDATA[A few new and cool CSS3 styles become realistic options when building a website if you combine them with IE's filter.]]></description>
			<content:encoded><![CDATA[<p><a class="button demo" href="/article-data/demo/CSS3/CSS3.html" target="_blank"><span> </span>View demo</a>
<div class="clear"></div>
<p>A few new and cool CSS3 styles become realistic options if you are designing website. That is: as long as you combine them with IE’s counterpart filter.</p>
<p>The list of things that Safari, Chrome and Firefox support is getting larger and larger. Not all functionality is that interesting since we still have to make sure that IE users receive a functional site. And if you&#8217;re building something for a customer, you have to make sure that the website looks like what the customer expects it to look like. Most of the time that means that the website must be more or less an exact copy of the designs in Photoshop.</p>
<p>But what is easily forgotten is that for years Internet Explorer sort of supports some CSS styles through the proprietary <code>filter</code> property. I mostly use <code>filter</code> for setting opacity or forcing alpha channels in a PNG24, but when I saw a text shadow in a website I realized that IE can do that trick already for years. So I came up with this list of things that should work on almost any browser:</p>
<ul>
<li>Text shadow</li>
<li>Box shadow</li>
<li>Blur</li>
<li>Gradient background</li>
<li>Opacity</li>
<li>PNG24 alpha</li>
</ul>
<h2>A little on browser support</h2>
<p>A little warning about the “works in”-lines you&#8217;ll seewith each example. I didn&#8217;t dig very deep to see which version of Opera started to support text-shadow. If see in a support chart that Opera 9.62 supports text-shadow, I haven&#8217;t dug deeper to if it was also supported in Opera 9.61. Especially when I relate it to the small share of people who use that browser. If you can point a source that speaks of an earlier version, I&#8217;m more than happy to correct the article.</p>
<h2>Things you can do with CSS and filters combined</h2>
<h3>Text shadow</h3>
<p><strong>Works in IE 5.5+, Firefox 3.1b+, Safari 3+, Chrome 2+ and Opera 9.62+</strong><br />
Used sparingly can create a nice subtle effect and is a great way to make something a bit more stylish. Watch out with loss of anti-alias. More on that issue at the end of the article.</p>
<div class="wp-caption alignleft" style="width: 163px"><img title="Text-shadow in IE8" src="/article-data/images/IE-filter-textshadow-ie.png" alt="Text-shadow in IE8" width="153" height="13" /><p class="wp-caption-text">Text-shadow in IE8</p></div>
<div class="wp-caption alignleft" style="width: 165px"><img title="Text-shadow in Firefox 3.5.5" src="/article-data/images/IE-filter-textshadow-ff.png" alt="Text-shadow in Firefox 3.5.5" width="155" height="14" /><p class="wp-caption-text">Text-shadow in Firefox 3.5.5</p></div>
<pre name="code" class="css:nogutter">.textShadow {
	width: 250px;
	text-shadow: 1px 1px 1px #cccccc; /* CSS3-compatible browsers */
	filter: dropshadow(color=#cccccc, offx=1, offy=1) /* IE */
}</pre>
<h3>Blur</h3>
<p><strong>Works in IE 5.5+, Firefox 3.1b+, Safari 3+, Chrome 2+ and Opera 9.62+</strong><br />
This one is a bit of hack: CSS3&#8217;s <code>text-shadow</code> is misused to create a blur. It was a trick I saw on www.css-tricks.com (hence the name, I guess). And although you can see the differences between the two screenshots, both are definitely blurs. A <a href="/conditional-comments/">conditional comment</a> was used to make the text in IE a bit darker so it would match with other browsers.</p>
<div class="wp-caption alignleft" style="width: 79px"><img title="Blur in IE8" src="/article-data/images/IE-filter-blur-ie.png" alt="Blur in IE8" /><p class="wp-caption-text">Blur in IE8</p></div>
<div class="wp-caption alignleft" style="width: 85px"><img title="Blur in Firefox 3.5.5" src="/article-data/images/IE-filter-blur-ff.png" alt="Blur in Firefox 3.5.5" /><p class="wp-caption-text">Blur in Firefox 3.5.5</p></div>
<pre name="code" class="css:nogutter">.blur {
	width: 250px;
	color: #ddd;
	text-shadow: 0 0 2px #aaaaaa;
	text-shadow: 0 0 4px #aaaaaa;
	text-shadow: 0 0 6px #aaaaaa;
	filter:
		progid:DXImageTransform.Microsoft.MotionBlur(strength=1,direction=310)
		progid:DXImageTransform.Microsoft.Blur(pixelradius=2);
}</pre>
<pre name="code" class="css:nogutter">&lt;!--[if IE]&gt;
	&lt;style type="text/css"&gt;
		/* This style is for IE browsers only by
		   using IE's Conditional Comments */
		.blur {
			color: #aaaaaa;
		}
	&lt;/style&gt;
&lt;![endif]--&gt;</pre>
<h3>Opacity</h3>
<p><strong>Works in IE 5.5+ and in all major browsers for years and is safe to use</strong><br />
Definitely the most used combination of CSS and IE&#8217;s filter. I mostly use it to make the website almost invisible in favor of an absolute placed <code>div</code> which floats like popup window on top of the greyed out website.</p>
<div class="wp-caption alignleft" style="width: 149px"><img title="Opacity 0.5 in IE8" src="/article-data/images/IE-filter-opacity-ie.png" alt="Opacity 0.5 in IE8" /><p class="wp-caption-text">Opacity 0.5 in IE8</p></div>
<div class="wp-caption alignleft" style="width: 149px"><img title="Opacity 0.5 in Firefox 3.5.5" src="/article-data/images/IE-filter-opacity-ff.png" alt="Opacity 0.5 in Firefox 3.5.5" /><p class="wp-caption-text">Opacity 0.5 in Firefox 3.5.5</p></div>
<pre name="code" class="css:nogutter">.opacity {
	width: 250px;
	opacity: 0.5;
	-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";/*IE8+*/
	filter: alpha(opacity=50); /* IE7 and lower */
}</pre>
<h3>Gradient</h3>
<p><strong>Works in IE 5.5+, Firefox 3.6+, Safari4, Chrome 3+</strong><br />
The soon to be released Firefox 3.6 supports gradient background. Safari and Chrome already supports that cool CSS3 feature. Although you can do more with CSS3&#8217;s background gradient than IE&#8217;s filter, there&#8217;s nothing to stop you from using a simple gradient. Well, poor browser support may stop you. Firefox 3.6 still has to be released and Opera does not seem to support gradients at all.</p>
<p>So the browser support for gradients is less than desirable. But since all major browsers except Opera now supports gradients in their latest versions, it will become a useful styling tool soon.</p>
<div class="wp-caption alignleft" style="width: 180px"><img title="Background gradient in IE8" src="/article-data/images/IE-filter-gradient-ie.png" alt="Background gradient in IE8" /><p class="wp-caption-text">Background gradient in IE8</p></div>
<div class="wp-caption alignleft" style="width: 180px"><img title="Background gradient in Chrome 3.0" src="/article-data/images/IE-filter-gradient-chrome.png" alt="Background gradient in Chrome 3.0" /><p class="wp-caption-text">Background gradient in Chrome 3.0</p></div>
<pre name="code" class="css:nogutter">.gradient {
	background: -moz-linear-gradient(top, bottom,from(#cccccc),to(#888888));
	background: -webkit-gradient(linear, left top, left bottom, from(#cccccc), to(#888888)) no-repeat;
	background; -o-gradient(top, bottom,from(#cccccc),to(#888888));
	-ms-filter: "progid:DXImageTransform.Microsoft.gradient (GradientType=0, startColorstr=#ffcccccc, endColorstr=#ff888888)"; /* IE8+ */
	filter: progid:DXImageTransform.Microsoft.gradient (GradientType=0, startColorstr=#ffcccccc, endColorstr=#ff888888); /* IE7 and lower */
}</pre>
<h3>Box shadow</h3>
<p><strong>Works in IE 5.5+, Firefox 3.6+, Safari 3, Chrome 1</strong><br />
If you look at the screenshots below you see a striking difference in what is called a “Shadow“. IE&#8217;s box shadow looks more like the right and bottom side of a 3D object than a real life shadow. CSS3&#8217;s box-shadow provides a shadow that&#8217;s much more realistic.</p>
<p><img title="Box shadow in IE8" src="/article-data/images/IE-filter-shadow-ie.png" alt="Box shadow in IE8" /><img title="Box shadow in Firefox 3.5.5" src="/article-data/images/IE-filter-shadow-ff.png" alt="Box shadow in Firefox 3.5.5" /></p>
<pre name="code" class="css:nogutter">.boxShadow {
	-moz-box-shadow: 5px 5px 5px #888;
	-webkit-box-shadow: 5px 5px 5px #888;
	-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(color=#888888,direction=125,strength=5)"; /* IE8+ */
	filter: progid:DXImageTransform.Microsoft.Shadow(color=#888888,direction=125,strength=5); /* IE7 and lower */
	background: #cccccc;
}</pre>
<h3>Use alpha channel in PNG24 images</h3>
<p>Not really a CSS feature, neither something that lacks in modern IE browsers. But it is dearly missed in IE6. The only way to use alpha channels in IE6 (although many have found different ways apply it) is by using the filter&#8217;s AlphaImageLoader. Although this filter can save the day, it has many bugs you need to be aware of:</p>
<ul>
<li>It can only be used as a background image.</li>
<li>You cannot position it like a normal background image, nor can the image repeat itself on the <code>x</code> or <code>y</code> axis.</li>
<li>Links or form elements inside a box with a transparent PNG24 are not clickable. You have to make sure that such elements have a parent that has <code>position: relative</code>.</li>
<li>Having lots of relative positioned elements scattered around can add extra complexity to your website if it has absolute positioned items floating on top of each other as well.</li>
<li>You&#8217;ll lose text anti-alias.</li>
</ul>
<p><strong>This technique is only needed in IE6. Other modern browsers use the alpha channel as it ought to be.</strong></p>
<pre name="code" class="css:nogutter">.imageAlpha {
	display: block;
	width: 250px;
	height: 40px;
	padding: 5px 10px;
	background: #aaf url(alpha.png) 0 0 repeat-x; /* PNG24 image with alpha layer that works in all modern browsers */
}
* html .imageAlpha { /* these styles are only picked up by IE6 */
	background-image: none;
	filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='alpha.png', sizingMethod='scale')
}</pre>
<h2>Filter bugs</h2>
<h3>Filter can clear Cleartype</h3>
<p>The main drawback of using IE&#8217;s <code>filter</code> is that in some cases the element that has a filter style in IE, will lose it&#8217;s anti-aliasing. That may not sound like a big deal, because we have lived for a long time without Microsoft&#8217;s Cleartype, but it can get real ugly with larger fonts as you can see in the screenshots below. If you use a filter and it does remove the Cleartype, it&#8217;s best to keep the font-size 16 pixels or lower.</p>
<p><img title="IE filters in Arial 16px" src="/article-data/images/IE-filter2.png" alt="IE filters in Arial 16px" /><img title="IE filters in Georgia 19px" src="/article-data/images/IE-filter1.png" alt="IE filters in Georgia 19px" /></p>
<h3>Filters can only be applied to boxes</h3>
<p>Filters can only be applied to block elements like <code>div</code> or <code>p</code> and they need a width or height. If not, the filter won&#8217;t work. The exception to the rule is IE8, which can show filter effects without a width or height.</p>
<p><a class="button demo" href="/article-data/demo/CSS3/CSS3.html" target="_blank"><span> </span>View demo</a>
<div class="clear"></div>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thebrightlines.com/2009/12/03/using-ies-filter-in-a-cross-browser-way/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>The trouble with @font-face</title>
		<link>http://www.thebrightlines.com/2009/11/01/the-trouble-with-font-face/</link>
		<comments>http://www.thebrightlines.com/2009/11/01/the-trouble-with-font-face/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 12:02:01 +0000</pubDate>
		<dc:creator>Wouter Bos</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Webfonts]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[EOT]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[fonts]]></category>

		<guid isPermaLink="false">http://www.thebrightlines.com/?p=73</guid>
		<description><![CDATA[All major browsers are able to display fonts that are not installed on the computer, but downloadable from the web through the CSS-technique @font-face. But there are some caveats.]]></description>
			<content:encoded><![CDATA[<p>Finally it seems like we&#8217;re getting rid of the shackles of webfonts. With the implementation of the CSS-technique @font-face in Firefox 3.5, Safari and Opera we&#8217;re not only able to choose between fonts like Arial, Times and Courier, but also between any TTF or OTF on our computers. IE already had an implementation of @font-face for years that only supports a proprietary format called EOT,  but both 2 techniques work together perfectly in one CSS file.</p>
<h2>If custom fonts are so great, Why isn&#8217;t anyone using it?</h2>
<p>In case you&#8217;re already in the process of removing that lame Times New Roman from your computer: look around on the web. There&#8217;s almost no website to be found that shows non-standard fonts through the @font-face technique. They all use images or sIFR. So why is no-one using @font-face? I decided to set up a <a href="http://www.thebrightlines.com/article-data/downloads/font-face2/index.html" target="_blank">@font-face test page</a> and try it in different browsers and found a few shortcomings:</p>
<h3>No Chrome</h3>
<p>Although Chrome is <em>able</em> to show custom fonts it&#8217;s disabled by default as reported on <a href="http://opentype.info/blog/2009/04/16/google-chrome-with-webfonts-support/">opentype.info</a>. It appears that you can enable it by adding the option <code>-enable-remote-fonts.</code> It&#8217;s not clear if remote fonts are going to enabled by default soon, but I guess the Chrome team first have to address security issues that come with the use of webfonts.</p>
<h3>Text flashing in Firefox</h3>
<p>When loading the page, Firefox first shows the text in a default font. Only after the TTF or OTF is loaded, it will change the text accordingly. Even when I reload the page, the texts in the web page flashes from web font to TrueType font. Although it&#8217;s not a a nice effect, it&#8217;s no disaster either.</p>
<h3>IE7+ in high security level</h3>
<p>IE7 and IE8 in the highest security level will not show custom fonts, but will show a webfont. I&#8217;ve never ever had IE in the highest security level, but I reckon some will. And I guess many large organizations will have IE set to the highest security level. So be prepared that some people won&#8217;t see your carefully crafted website like you intended.</p>
<h3>Deal breaker: IE6 in high security level</h3>
<p>Well, until now the worst that could happen is that a browser won&#8217;t show a custom font but will default to a system font installed on your computer. But using custom fonts in IE6 is close to impossible. IE supports @font-face since IE4, but after the release of IE6 Microsoft decided to crank up the security. This resulted in a dialogue box that nicely asks if you&#8217;d like to download the custom font that might be a security breach. No problem. Until you click a link. Or even refresh the page. You&#8217;ll get that dialogue box once again. Huh? Didn&#8217;t I just answer that question? I&#8217;m still on the website, so why do I have to decide once again if I want to download a font that&#8217;s most likely still in my cache?</p>
<p><img class="alignright" title="The dreaded IE6 popup that just wont go away" src="http://www.thebrightlines.com/article-data/images/IE6-fontface.png" alt="" />There goes your usable website down the drain. Like I said: I don&#8217;t think that many people will have their security set that high, but it still is a real deal breaker. I suggest that it&#8217;s best to show no custom fonts at all in IE6. You can do that by loading an alternate CSS file with <a href="http://www.quirksmode.org/css/condcom.html">conditional comments</a> (tip of a colleague of mine). No fancy fonts is still better than the risk of scaring away visitors.</p>
<h3>Last but not least: Converting fonts to EOT</h3>
<p>Like I said earlier: Microsoft does not support TTF or OTF. That&#8217;s because if you link your CSS to a font file it has to be downloadable for anyone. That&#8217;s sour if you just paid a few hundred bucks for some premium font. Not to mention for the persons or companies who made that font. So Microsoft came up with a font format that&#8217;s not usable as a regular font and that&#8217;s restricted to some specific list of domains. Perfect.</p>
<p>But WEFT, the program to create EOT font files that Microsoft publicized, is awkward in use (if you ask me) and just doesn&#8217;t work on my Vista PC. It crashes before I&#8217;m able to convert a single font. There is an open source program called <a href="http://code.google.com/p/ttf2eot/">ttf2eot</a> and there are even websites that convert fonts with that program like the one on <a href="http://www.kirsle.net/wizards/ttf2eot.cgi">www.kirsle.net</a>. But ttf2eot is still version 0.0.2-2, so that sounds very alpha to me although it seems to do a good job. So be sure to check first if you are able to convert a font before you promise something to the costumer.</p>
<p>An other way to protect the authors of fonts (and yourself as a user that paid a lot of money) is the use of <a href="http://opentype.info/blog/2009/07/29/why-webfont-services-are-the-future-of-fonts-on-the-web/">webfont services</a> that supply the raw font. That way you can use a specific font without having to worry that you become an unintentionally illegal provider of premium fonts.</p>
<h2>But it will still change the web</h2>
<p>So there are still some hurdles to overcome. But it&#8217;s clear that it won&#8217;t take long before the web will be significantly different from what we know now because the use of custom fonts. Although I&#8217;m convinced that with the plethora of available fonts, system fonts like Arial will stay an all-time favorite for a long time.</p>
<h2><em>Update</em></h2>
<p>I had some good feedback (see comments) with some great links:</p>
<ul>
<li><a href="http://www.fontsquirrel.com/fontface/generator">ttf2eot tutorial</a></li>
<li><a href="http://www.fontsquirrel.com/fontface/generator">Font squirrels font font-face generator</a></li>
<li><a href="http://nicewebtype.com/notes/2009/10/30/how-to-use-css-font-face/">How to use CSS font-face</a></li>
<li><a href="http://www.alistapart.com/articles/dynatext/">PHP font replacement</a></li>
</ul>


<p>Related posts:<ol><li><a href='http://www.thebrightlines.com/2010/01/12/implementing-font-face-cross-domain/' rel='bookmark' title='Permanent Link: Implementing font-face cross domain'>Implementing font-face cross domain</a></li>
<li><a href='http://www.thebrightlines.com/2009/11/07/no-sign-of-font-face-in-chrome-4/' rel='bookmark' title='Permanent Link: No sign of @font-face in Chrome 4'>No sign of @font-face in Chrome 4</a></li>
<li><a href='http://www.thebrightlines.com/2009/12/10/251/' rel='bookmark' title='Permanent Link: My favorite for converting fonts to EOT'>My favorite for converting fonts to EOT</a></li>
<li><a href='http://www.thebrightlines.com/2010/01/20/webfont-pitfalls/' rel='bookmark' title='Permanent Link: Webfont pitfalls'>Webfont pitfalls</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.thebrightlines.com/2009/11/01/the-trouble-with-font-face/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
