CSS Battle: IE vs Firefox

JavaScript and client side scripting.

Moderator: General Moderators

BigAbe
Forum Commoner
Posts: 66
Joined: Fri Mar 31, 2006 7:41 pm

CSS Battle: IE vs Firefox

Post by BigAbe »

Any good tips for handling IE/Firefox compatible CSS?

I've got my pages displaying differently in the two browsers and I really don't want to have to manually define each item line by line.

-- Abe --
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

Show the specific code with a problem, and we can give specific solutions to the problem.

In general, use conditional statements for browser-specific issues.
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

Roja wrote:use conditional statements for browser-specific issues.
Hmm! Personally that wouldn't be my recomendation. I'd say use CSS that is valid and that works and displays well in all browsers. Steer well clear of all solutions that aim to "fix" something in one browser.
BigAbe
Forum Commoner
Posts: 66
Joined: Fri Mar 31, 2006 7:41 pm

Post by BigAbe »

Code: Select all

p {font-family: verdana; font-size: small}
#small {font-family: verdana; font-size: x-small}
img
{
 border-style: none;
}
p.small {font-family: verdana; font-size: x-small}

Code: Select all

print ("<p><a href=\"index.php?admincpcategories=1&subcatdeactivate=$subcatID\"><img src=\"../images/deactivate.gif\"  alt=\"De-activate\"></a>
<a href=\"index.php?admincpcategories=1&submodify=$subcatID\"><img src=\"../images/mod.gif\" alt=\"Modify\"></a>
<b>$subcatName</b> (#$subcatID)</p>");
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

Look at the Skidoo Too layout and csshover2.htc.

Lot's of great stuff there.
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

bokehman wrote:
Roja wrote:use conditional statements for browser-specific issues.
Hmm! Personally that wouldn't be my recomendation. I'd say use CSS that is valid and that works and displays well in all browsers. Steer well clear of all solutions that aim to "fix" something in one browser.
I couldn't have said that better.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

AKA Panama Jack wrote:
bokehman wrote:
Roja wrote:use conditional statements for browser-specific issues.
Hmm! Personally that wouldn't be my recomendation. I'd say use CSS that is valid and that works and displays well in all browsers. Steer well clear of all solutions that aim to "fix" something in one browser.
I couldn't have said that better.
There are situations where you simply cannot do that. I'm not talking about whacky DHTML stuff neither. For example have you ever tried playing with padding/margin on order & unordered lists and viewing the result in IE then in other browsers?

Using conditional comments if far better than the underscore hack. Granted, you can work around most of the box model issues by simply nesting <div> elements to create a fake padding/margin.
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post by matthijs »

I agree that conditional comments are the way to go.

What bokehman says is also true to some extent. You have to be careful with "fixes". Don't let them bite you ..

My approach is simple: start designing according to the standards, testing in a modern and standards supporting browser, for example Firefox.

Then, when your design is finished, start testing in other browsers and see if something's broken. Sometimes you don't have to do anything, other times something is broken in f.e. IE. Often, one or a few "fixes" in the css file specific for IE 5 or 6 is enough to get your layout working in that browser. Most often the problem has something to do with the box model or misinterpretation of floats. A search through positioniseverything.net will often help you find the problem.

The main advantage of using conditional comments is that all fixes for that browser are centralized. When it's time to ditch support for that browser, you'll only have to remove that css file. And your main stylesheets stay clean. Although I must admit i don't like the fact that the conditional comments are written in the html. It would be better to have them in the main css file in some way (like the MidPass filter from Tantek).
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I know this sounds foolish, harsh and arrogant, but I like to write standard compliant code. Hacks are a common thing because IE still chokes on a lot of standard stuff (can we say box model issues?). So naturally I am not a proponent for conditional loading of stylesheets. Almost any CSS compliance issue ca be reworked to make a close resemblance to conformance if you try hard enough and google enough.

Man, IE just chaps my... goodnight.
User avatar
phpdevuk
Forum Contributor
Posts: 220
Joined: Mon Jul 04, 2005 5:31 am
Location: UK
Contact:

Post by phpdevuk »

IE 7 renders CSS much better than IE6, I've found that most websites that are well written render pretty much the same in IE7 as they do in firefox. I have had the odd exception (buttons wandering off page, and a menu bar disappearing) but on the whole its a vast improvment over how IE6 handles CSS, I'm hoping when MS finally releases it we will see an end to need to having to code for two different browsers ;)
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

It's going to be a while before most people upgrade :(
BigAbe
Forum Commoner
Posts: 66
Joined: Fri Mar 31, 2006 7:41 pm

Post by BigAbe »

Daedalus- wrote:It's going to be a while before most people upgrade :(
But why upgrade to IE7 when you can download Firefox?

:twisted:
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

phpdevuk wrote:IE 7 renders CSS much better than IE6, I've found that most websites that are well written render pretty much the same in IE7 as they do in firefox.
That is just not true. Try viewing the acid test. This really shows how far behind the Gecko browsers it really is.
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

bokehman wrote:
phpdevuk wrote:IE 7 renders CSS much better than IE6, I've found that most websites that are well written render pretty much the same in IE7 as they do in firefox.
That is just not true. Try viewing the acid test. This really shows how far behind the Gecko browsers it really is.
Download the latest version of Opera 9 and check out the Acid 2 Test. Opera 9 gets it right. :D
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

oh just stop with the "user this browser" stuff guys. I've read it enough and now I'm tired of seeing it.
Post Reply