<?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; filter</title>
	<atom:link href="http://www.thebrightlines.com/tag/filter/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>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>
