View Full Version : using different CSS coding for IE and FireFox
jl9148
11-14-2006, 12:24 AM
i made a website that look perfect on firefox, yet on internet explorer- it happens to have a small flaw.
is there any way i can create codes different for each browser?
like if they are using IE- show code A
and if they are using FireFox- show code B
oracleguy
11-14-2006, 12:26 AM
Yeah you can. What you can do is have your main stylesheet work for firefox. Then make a second one that changes the values that needed to be changed to make the design work in IE. Then you can use conditional comments to make the second one only load under IE.
Example:
<link rel="stylesheet" type="text/css" href="/primary.css" />
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="/secondary.css" media="screen" />
<![endif]-->
mark87
11-14-2006, 12:43 AM
Also remember IE6 and below treat things a bit different to IE7 so you may wish to just specify the stylesheet just to version less than or equal to IE6.
<!--[if lte IE 6]>
Small flaws can also be delt with hacks such as the * html {} hack, where only IE processes the CSS.
jl9148
11-14-2006, 12:47 AM
is there a way to put a code in the actual .css file? or betweek the <style></style> tags?
mark87
11-14-2006, 12:55 AM
As I said, with the star html hack you can do that, but since IE7 has come along it's now discouraged...
jl9148
11-14-2006, 12:56 AM
so lets say i have a div that its ID="blah"
am i going to put..
* html #blah
{ }
mark87
11-14-2006, 12:58 AM
Yup.
* html #blah { margin-top: 10px }
...would make IE give #blah a top margin of 10px. Other browsers would ignore it.
felgall
11-14-2006, 03:28 AM
Yup.
* html #blah { margin-top: 10px }
...would make IE give #blah a top margin of 10px. Other browsers would ignore it.
...would make IE 6 and below give #blah a top margin of 10px. Other browsers including IE7 would ignore it.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.