<?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>ADM Blog &#187; comaptibility</title> <atom:link href="http://blog.another-d-mention.ro/tag/comaptibility/feed/" rel="self" type="application/rss+xml" /><link>http://blog.another-d-mention.ro</link> <description>No matter how you see things, reality changes when you reach understanding</description> <lastBuildDate>Fri, 22 Jul 2011 06:56:49 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1</generator> <item><title>How To &#8211; get Cross Browser Compatibility Every Time</title><link>http://blog.another-d-mention.ro/programming/css/how-to-get-cross-browser-compatibility-every-time/</link> <comments>http://blog.another-d-mention.ro/programming/css/how-to-get-cross-browser-compatibility-every-time/#comments</comments> <pubDate>Fri, 20 Feb 2009 17:15:05 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[How To's]]></category> <category><![CDATA[chrome]]></category> <category><![CDATA[comaptibility]]></category> <category><![CDATA[firefox]]></category> <category><![CDATA[ie6]]></category> <category><![CDATA[ie7]]></category> <category><![CDATA[ie8]]></category> <category><![CDATA[opera]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=37</guid> <description><![CDATA[Working with Internet Explorer can be a pain for the everyday web designer. But it doesn't have to be. Many, if not all, of the bugs can be fixed quickly and easily by understanding how the occur. I've put together a list of the major problems beginners have with cross browser compatibility. I'm only going [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/cross-browser-inline-block/' rel='bookmark' title='Permanent Link: Cross browser inline-block'>Cross browser inline-block</a></li><li><a
href='http://blog.another-d-mention.ro/programming/cheeky-little-tips-that-will-help-against-email-harvesting/' rel='bookmark' title='Permanent Link: Cheeky little tips that will help against email harvesting'>Cheeky little tips that will help against email harvesting</a></li><li><a
href='http://blog.another-d-mention.ro/programming/use-any-font-with-cufon/' rel='bookmark' title='Permanent Link: Use any Font with Cufon'>Use any Font with Cufon</a></li></ol>]]></description> <content:encoded><![CDATA[<p>Working with Internet Explorer can be a pain for the everyday web designer. But it doesn't have to be. Many, if not all, of the bugs can be fixed quickly and easily by understanding how the occur. I've put together a list of the major problems beginners have with cross browser compatibility.</p><p>I'm only going to be concerned with the major browsers - Firefox 2+, Safari 3+ and Internet Explorer 6+. IE6 is slowly declining.  If you know the IE6 bugs you can generally know if your site will break before you even check it in a browser. This isn't an article for the super-experienced web designer, but hopefully will give some insight to some people who don't understand the mysteries of IE6 and cross browser compatibility.</p><h2>Summary</h2><p>Here is a quick summary for those of you who don't want to read the whole article:</p><ul><li>Always use strict doctype and standards-compliant HTML/CSS</li><li>Always use a reset at the start of your css</li><li>Use -moz-opacity:0.99 on text elements to clean up rendering in Firefox, and text-shadow: #000 0 0 0 in Safari</li><li>Never resize images in the CSS or HTML</li><li>Check font rendering in every browser. Don't use Lucida</li><li>Size text as a % in the body, and as em's throughout</li><li>All layout divs that are floated should include display:inline and overflow:hidden</li><li> Containers should have overflow:auto and trigger hasLayout via a width or height</li><li>Don't use any fancy CSS3 selectors</li><li>Don't use transparent PNG's unless you have loaded the alpha</li></ul><h2>Element Inconsistencies</h2><p>Every browser renders particular elements differently - different amounts of padding, margins, borders etc. This means your site can look different in every browser if you use default styles.</p><p><strong>Solution</strong></p><p>The first thing you should do, which most people most likely know about, is to reset your styles. A reset is some css you place at the start of your styles that removes the padding, margin, border and other inconsistencies from elements, and rebuilds them in a standard way.</p><p>Download Eric Meyer's <a
href="http://meyerweb.com/eric/thoughts/2008/01/15/resetting-again/">reset.css</a> and place the code at the start of your styles. Bam! Clean, cross browser styles.</p><h2>Image Rendering</h2><p>IE6 and IE7 both render resized images extremely badly. When you change the size of an image with CSS or in the HTML, it appears blocky and edgy.<br
/> <strong>Solution</strong></p><p>Don't do it. Always size your images to your desired size before you use them on your site</p><h2>Font Rendering</h2><p>I told you not all issues were with IE. Safari 3+ has an issue with the way it renders light type on a dark background. Some would argue whether this is good or bad, but there's a way to make it appear lighter. Here's an example of standard white on black text rendering in Safari 3.1:</p><p><img
class="alignnone size-full wp-image-38" style="border: 1px solid black; padding: 3px;" title="safari-before" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/safari-before.png" alt="safari before How To   get Cross Browser Compatibility Every Time" width="351" height="165" /></p><p><strong>Solution</strong><br
/> Easy fix. You need to add this to your code.</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;">p <span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>Where #000 is your background colour. You will probably have to be more specific with the elements you select. I wouldn't suggest using this fix on the body tag. Other elements you might need to fix are the li, dt, dd, blockquote etc. Use this on any text element you want to appear 'thinner'</p><p>To make this fix in Firefox, you use the opacity fix:</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;">p <span style="color: #00AA00;">&#123;</span>
    -moz-opacity<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0.99</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>You need to be careful with this fix, as it will break any Flash element that it touches in Firefox. There appears to be no workaround for it.</p><p>The type will now be rendered like this:</p><p><img
class="alignnone size-full wp-image-46" style="border: 1px solid black; padding: 3px;" title="safari-after" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/safari-after.png" alt="safari after How To   get Cross Browser Compatibility Every Time" width="336" height="157" /></p><h2>Font Selection</h2><p>There are common web fonts that we use - Arial, Georgia, Verdana etc. But there are some fonts that are common to both PC and Mac and can be used - Century Gothic, Arial Narrow etc. However, different browsers and OS's render type different, and you need to be aware of these differences, as your site could look dam ugly if you use the wrong font.</p><p><strong>Solution</strong></p><p>The font you choose is ultimately up to you. As long as it's a safe font you will be fine. However you should be aware of these rendering issues. One font you should probably not use is Lucida Grande/Sans. It renders awful in IE. Take a look at its rendering in Safari(Mac):</p><p><img
class="alignnone size-full wp-image-47" style="border: 1px solid black; padding: 3px;" title="safari-lucida" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/safari-lucida.png" alt="safari lucida How To   get Cross Browser Compatibility Every Time" width="600" height="120" /></p><p>Looks nice doesn't it? Too bad it looks like this in Internet Explorer(PC):</p><p><img
class="alignnone size-full wp-image-48" style="border: 1px solid black; padding: 3px;" title="ie6-lucida" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/ie6-lucida.png" alt="ie6 lucida How To   get Cross Browser Compatibility Every Time" width="600" height="120" /></p><p>Some people have stated that Lucida Sans will look fine in IE with ClearType, and others have said that it still looks bad. A smart alternative is to just not use Lucida Sans as your 'fallback font', and instead use Arial or another san-serif font.</p><h2>Font Sizing</h2><p>The ability to resize text differs amongst browsers and OS's. IE won't resize text thats set in pixels. If we set all text in em's, IE will exaggerate the text sizes when resized.</p><p><strong>Solution</strong></p><p>The best reference for font sizing is the article <a
href="http://www.alistapart.com/articles/howtosizetextincss">How to Size Type in CSS</a> by Richard Rutter. The results - You need to specify the size as a percentage in the body element, and then size it in em's through the rest of the sheet. For line height, you need to define it in em's, rather than pixels, for consistent rendering.<br
/> One thing to remember is that the default font size is 16px. So to resize our type to 12px we use:</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">75%</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.5em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>Now you can size your type in em's like so:</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;">h1<span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">3em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>Another suggested technique is to resize it down to 10px, which makes it easier to size upwards in em's. For example.</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">62.5%</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.5em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
h1 <span style="color: #00AA00;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.8em</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* 18px */</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
p <span style="color: #00AA00;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.2em</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* 12px */</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>here is an issue with this however, if people use small font option in Internet Explorer, it could be so small that it's unreadable. It's only a small chance. But worth noting.</p><h2>Double Margins on Floats</h2><p>We create CSS layouts by floating div's up against each other, like some form of horizontal tetris. When it reaches the end of a row, it drops down to the next. The common method for creating a grid is this:</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#content</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;">right</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#sidebar</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;">right</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>This is what it should look like in a browser:</p><p><img
class="alignnone size-medium wp-image-58" style="border: 1px solid black; padding: 3px;" title="doublemargin-ff" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/doublemargin-ff-300x264.png" alt="doublemargin ff 300x264 How To   get Cross Browser Compatibility Every Time" width="300" height="264" /></p><p>This is what IE does to it:</p><p><img
class="alignnone size-full wp-image-59" style="border: 1px solid black; padding: 3px;" title="doublemargin-ie" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/doublemargin-ie.png" alt="doublemargin ie How To   get Cross Browser Compatibility Every Time" width="400" height="353" /></p><p>The margin width is doubled. Any margin that is on the same side as the float will be doubled. Don't ask why. It's just IE. This means the element on the left will have that margin stretched out to 20px, which will probably break the layout.</p><p><strong>Solution</strong></p><p>To fix it, all you need to do is put display:inline on your layout divs.</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#content</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;">right</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</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>
&nbsp;
<span style="color: #cc00cc;">#sidebar</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;">right</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</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></pre></div></div><p>Now that margin bug is all fixed. Even though it only effects margins on the same side as the float, it can still be useful to include this fix. You never know when you might use a margin on the float side. It won't effect any other browser, so you can use it safely.</p><h2>Expanding Box</h2><p>The expanding box problem is a big issue with many css layouts. When you have a standard layout, with floats sitting next to each other, with set widths, but an image or long string of text is longer than this width, the layout will break in IE6. Take a look at this example:</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#content</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;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</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>
&nbsp;
<span style="color: #cc00cc;">#sidebar</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;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</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></pre></div></div><p>This will render like in this most browsers:</p><p><img
class="alignnone size-full wp-image-63" style="border: 1px solid black; padding: 3px;" title="expandingbox" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/expandingbox.png" alt="expandingbox How To   get Cross Browser Compatibility Every Time" width="400" height="353" /></p><p>However, in IE6, it will break like so:</p><p><img
class="alignnone size-full wp-image-64" style="border: 1px solid black; padding: 3px;" title="expandingbox-ie" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/expandingbox-ie.png" alt="expandingbox ie How To   get Cross Browser Compatibility Every Time" width="400" height="353" /></p><p><strong>Solution</strong></p><p>The solution is to use the overflow property. If you place overflow:hidden; into the layout divs, the layout won't break in IE6.</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#content</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;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</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: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#sidebar</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;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</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: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>This could, however, cause some issues with layouts depending on how complex they are. It also won't cause the text to wrap, and it will just remain hidden. It's unlikely you'll have a string long enough to break a layout, but it could happen. Another option is to use word-wrap: break-word; in an IE specific stylesheet. This won't effect images though, so you'll have to make a choice about with method is appropriate for your situation.</p><h2>Clearing Floats</h2><p>What we mean when we talk about clearing floats, is when a container or wrapper div doesn't correctly wrap around the containing divs. Take a look at this example:</p><p><img
class="alignnone size-full wp-image-66" style="border: 1px solid black; padding: 3px;" title="clearing" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/clearing.png" alt="clearing How To   get Cross Browser Compatibility Every Time" width="400" height="353" /></p><p>See how the container is correctly containing the div's? This is what should happen. However, sometimes it does not clear correctly, like so:</p><p><img
class="alignnone size-full wp-image-67" style="border: 1px solid black; padding: 3px;" title="noclearing" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/noclearing.png" alt="noclearing How To   get Cross Browser Compatibility Every Time" width="400" height="353" /></p><p>The container isn't correctly wrapping around it. You probably won't notice this until you try and put a background on your container.</p><p><strong>Solution</strong></p><p>There are a few different solutions for clearing. The best solution however, is a simple <strong>overflow:auto</strong> or <strong>overflow:hidden</strong> in your container</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#container</span> <span style="color: #00AA00;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">966px</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
     <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>You need to keep in mind that overflow:auto might cause some issues in Firefox. If you do have any issues, use overflow:hidden instead. If this is still causing issues, take a look at <a
href="http://www.sitepoint.com/blogs/2005/02/26/simple-clearing-of-floats/">some other forms of clearing floats</a>. Apart from just adding this, you'll need to make sure hasLayout is triggered in IE6. You can do this by specifying a width or height. If you don't have a width in your container, you can use height:1% to trigger it, or zoom:1; if you can't afford to give it a height.</p><h2>CSS Selectors</h2><p>Although we would like to use all the brand spanking new CSS3 selectors, IE6 doesn't support all of the major ones. There are also still some CSS2 child and sibling selectors you simply shouldn't use if you want to support IE6:</p><ul><li>E &gt; F</li><li>E + F</li><li>E ~ F</li><li>:root</li><li>:last-child</li><li> <img
src='http://blog.another-d-mention.ro/wp-includes/images/smilies/icon_surprised.gif' alt="icon surprised How To   get Cross Browser Compatibility Every Time" class='wp-smiley' title="How To   get Cross Browser Compatibility Every Time" /> nly-child</li><li>:nth-child()</li><li>:nth-last-child()</li><li>:first-of-type</li><li>:last-of-type</li><li> <img
src='http://blog.another-d-mention.ro/wp-includes/images/smilies/icon_surprised.gif' alt="icon surprised How To   get Cross Browser Compatibility Every Time" class='wp-smiley' title="How To   get Cross Browser Compatibility Every Time" /> nly-of-type</li><li>:nth-of-type()</li><li>:nth-last-of-type()</li><li>:empty</li><li>:not()</li><li>:target</li><li>:enable</li><li>:disabled</li><li>:checked</li><li>Any of the E[attribute] Selectors</li><li>:first-child</li><li>:lang()</li><li>:before</li><li>::before</li><li>:after</li><li>::after</li></ul><p>f course, a lot of these selectors aren't supported by even Firefox 3. For a full list of supported selectors, check out evotech.net's post on <a
href="http://www.evotech.net/blog/2008/05/browser-css-selector-support/">browser css selector support</a></p><p><strong>Solution</strong></p><p>Stick to your standard selectors. Nothing fancy. Only use E + F, E &gt; F, E ~ F when it won't make a huge difference in IE. If you really need to use these selectors, you should look at using IE8.js which gives IE6 better selector support. However this will slow down your site. But we don't really care about IE6 users do we?</p><h2>PNG Transparency</h2><p>IE6 doesn't support alpha transparency in PNG's. This is possibly the most annoying bug/issue with IE.</p><p><strong>Solution</strong></p><p>There are a few solutions for this problem. You can either use AlphaImageLoader in an IE specific stylesheet, link to a behaviour file in an IE specific stylesheet or use JS to fix the issue. Not matter which way you choose, there is no way to have transparent repeating background images.<br
/> To use AlphaImageLoader, it's a little bit tricky. Add these properties to any png image you want to have transparency. (You need to put this code in an IE specific stylesheet if you want your CSS to validate)</p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.trans</span> <span style="color: #00AA00;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
     filter<span style="color: #00AA00;">:</span> progid<span style="color: #3333ff;">:DXImageTransform</span><span style="color: #6666ff;">.Microsoft</span>.AlphaImageLoader<span style="color: #00AA00;">&#40;</span>src<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'/images/transparent.png'</span><span style="color: #00AA00;">,</span> sizingMethod<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'image/scale/crop'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div><p>Let's say you've given all your png image tags a class "trans", you select them with your css and use the filter property. You need to create a 1x1 transparent png file and link to it in the src attribute.</p><p>An even better way to do this is via a behaviour. It's similar to the AlphaImageLoader, except that you link to a behaviour script that triggers the transparency.</p><p>The third method is to use IE8.js which I mentioned earlier. It's even safer than the previous method, and you are very unlikely to run into any problems. Link to the script in your HTML, and it will make any png ending in -trans alpha-capable. eg. myimage-trans.png.</p><p><strong>With all this methods, you need to be aware that you might still run into problems with transparent pngs. Make sure you test it in IE6 extensively</strong></p><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/cross-browser-inline-block/' rel='bookmark' title='Permanent Link: Cross browser inline-block'>Cross browser inline-block</a></li><li><a
href='http://blog.another-d-mention.ro/programming/cheeky-little-tips-that-will-help-against-email-harvesting/' rel='bookmark' title='Permanent Link: Cheeky little tips that will help against email harvesting'>Cheeky little tips that will help against email harvesting</a></li><li><a
href='http://blog.another-d-mention.ro/programming/use-any-font-with-cufon/' rel='bookmark' title='Permanent Link: Use any Font with Cufon'>Use any Font with Cufon</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/programming/css/how-to-get-cross-browser-compatibility-every-time/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> </channel> </rss>
