FruitNotes beta
Your All-in-One Online Notebook
FruitNotes Blogs | Home  
CSS Browser Hacks - IE6 vs IE7 vs Firefox
Last updated at (Fri Jan 16 2009 21:47:54)
Posted by: Nitin Gupta
0%




Reference: http://www.tomjepson.co.uk/tutorials/14/css-browser-hacks.html#ie6

CSS Browser Hacks

Sorry, this tutorial is incomplete.

Here we're going to have a look at a few CSS browser hacks which you can use in those horrible situations where the page looks perfect in all browsers apart for one (IE6 cough!).

@import

@import is used to link an external stylesheet from within a stylesheet/CSS. Earlier version 4 browsers (e.g. Netscape Navigator 4) do not understand this rule and therefore ignore it.

Use the @import if you need to hide styles from older version 4 browsers:

@import "mystyle.css";      /* hidden from most version 4 browsers  */
@import url('mystyle.css'); /* understood by IE4 but not NN4 */

<!--[if IE]> Conditional Statements

Internet Explorer (aka IE) have conditional statements that allow you to give instructions based on the IE and the version of Internet Explorer running.

<!--[if IE]>
This will echo if the browser is Internet Explorer
<![endif]-->
<!--[if IE 5.5]>
This will echo if the browser is Internet Explorer version 5.5
<![endif]-->
<!--[if IE 6]>
This will echo if the browser is Internet Explorer version 6
<![endif]-->

IE 6 Only Hack

If everything works in Firefox, IE7 but not in Internet Explorer 6, use the star html hack:

* html .myclass{
/* this will only work in IE6	*/
}

 You can also use the underscore hack but I prefer not to as this will cause validation errors in your CSS. Just for reference, here's an example of the underscore hack:

p{
margin:0;  
_margin-left:5px; /* only IE6 will process this line */
}

Firefox Only Hack

I came up with this when messing around with child selectors. I don't know whether it has a name or if other people are using it but it seems to work quite nicely in the version of firefox I was running... (I haven't tried it in other browsers but  it validates fine)

Update: its called the child hack. Opera and Safari should process this aswell.

p.myStyle{
color:red;
}
p > .myStyle{
color:blue; /* Only Firefox runs this style */
}

Everything but IE6

Heres a hack that works in Firefox and IE7. Handy if you want everything but IE6 to run it. Better still, it validates as well.

html[xmlns] .myStyle{ 
/* Firefox and IE7 process this but the document must be XHTML to work */ 
}

To Hack or not to Hack?...

A lot of the time CSS hacks are just a quick solution for us developers, we don't care how it works as long as it does. However, my advice is avoid this and try to find out why there is a problem in the first place.

A little time spent looking into the problem itself and not a workaround will not only give you a far better understanding of CSS and browser iregularities but also stop you repeating the same thing the next time round.

Tutorial Name: CSS Hacks

Related Tutorials:


Rate this blog

   Report Abuse


Comments


From wei jing at Mon Aug 09 2010 10:26:10 GMT 0800 (China Standard Time)

UGG Boots on sale beauty with from UGG Classic Short Boots one of her favourite UGG Classic Tall Boots songs, Coco. She was UGG Argyle Knit Boots nearly 20 when she caught UGG Bailey Button Boots the eye of a dashing UGG Classic Cardy Boots .Above all Vibram Five Fingers, when you Timberland Shoes are doing Prada Shoes other there Gucci Shoes are different Coach Bags women’s are different Coach New Style Bags women’s women’s are different Coach New Style Bags women’s Louis Vuitton Bags for various Prada Bags occasions. Chanel Bags Let’s Gucci Bags say you Tous Bags can strappy Jimmy Choo Bags beach classic ghd Hair Straighteners or neutral beach classic ghd Straighteners or neutral beach classic ghd Straighteners sale or neutral beach classic ghd Hair Straighteners sale or neutral beach classic ghd Hair Straighteners on sale or neutral beach classic ghd Straightener on sale or neutral beach classic ghd Straightener outlet or neutral beach classic ghd hair Straightener outlet or neutral beach classic ghd outlet or neutral beach classic ghd on sale or neutral beach classic ghd sale or neutral MBT Shoes shaded MBT Sandals pump for formal Ray Ban Sunglasses, strappy sandals Chanel Jewelry for the evening or sexy Chanel Jewelry online for the evening Tiffany Jewelry and beach.



-----------
From dgff fdgfh at Tue Aug 03 09:57:05 2010

linda It's unfortunate that those who could best benefit from the Gucci Shoes Sale won't read it. They'll simply see it as an dunk low on a sacred icon. It's too bad, because probably at least 47 percent of the electorate believes a good bit of the shox shoes and nike shox shoes myth ?not a comforting thought. The author's Air Jordan Shoes and Air Jordans are reasonable look at the huge discrepancy between what Reagan supposedly did and his actual ugg classic boots. It is not Reagan bashing, though certainly some much-needed balance is achieved in assessing Michael Jordan Shoes's presidency. He is most assuredly correct to suggest that if we are to have a Coach Handbags at a bright future, we must, at the very least Cheap Jordans, move beyond myths. The book does tend to be a bit Cheap MBT Shoes and repetitious.

-----------

Leave your comment(s) below:
To start Your own Blog




Other Blogs
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
» 
2007 FruitNotes.com - All Rights Reserved.