We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Valid CSS Hack for IE?; Amazing
Topic Started: Jun 13 2005, 11:24 AM (496 Views)
JoeC
Euch! IE tastes horrible!
[ *  *  *  *  * ]
Ever made a website, viewing it in FireFox as your default browser, only to find that when you view it in IE, everything looks totally bodged? Or vice versa?

You still want W3C validity for your CSS and (X)HTML, but you don't want to spend six hours trying to tweak your site to provide a sub-standard version which displays in the major browsers.

Well, Do Not Fear!

I don't know how many other people know this, but in your CSS, if you put " * html " before a selector, only IE interprets it as a selector. For example...

Code:
 
body {
        background-color: #000;
        color: #FFF
}

* html body {
        background-color: #FFF;
        color: #000
}


Will show a black page with white text in Mozilla, Netscape, etc, but a white with black text on it in IE.

And you can even validate it against the W3C (X)HTML Validator and the W3C CSS Validator and it'll come out VALID in both cases.

Aaaah, a job well done :P
Offline Profile Quote Post Goto Top
 
solinent
Member
[ *  *  * ]
REALLY!!!!

OMFG~~!!!!!

I spent all of 10 minutes creating serverside scripting to do that :( lol :)
Offline Profile Quote Post Goto Top
 
Gornakle
Member
[ *  *  *  *  * ]
You could also use:

Code:
 
div {
 width: 20px !important;
 width: 22px;
}


IE will use the 22px width, all other browsers the 20px width.
Offline Profile Quote Post Goto Top
 
JoeC
Euch! IE tastes horrible!
[ *  *  *  *  * ]
Yeah well...I've had the problem several times, and I can't do ServerSide scripting :P Just starting to learn PHP and SQL as it is.
Offline Profile Quote Post Goto Top
 
Dennis
Member
[ *  *  *  *  *  *  * ]
Whoa. Nice trick. Thanks Joe.
Offline Profile Quote Post Goto Top
 
JoeC
Euch! IE tastes horrible!
[ *  *  *  *  * ]
You see, sol, Gorn, someone appreciates me taking a minute to post it :P
Offline Profile Quote Post Goto Top
 
Gornakle
Member
[ *  *  *  *  * ]
Alright.. alright..
W00h! OMG that rockz!! You rule Joezif!! :w00t:

.. happy now? :P
Offline Profile Quote Post Goto Top
 
JoeC
Euch! IE tastes horrible!
[ *  *  *  *  * ]
Very ;)
Offline Profile Quote Post Goto Top
 
solinent
Member
[ *  *  * ]
YEAH!!!

GO joeseifh!(I am BAD at spelling)

i was complementing you before, just that 10 minutes is reall alot to me :/ :geek:
Offline Profile Quote Post Goto Top
 
JoeC
Euch! IE tastes horrible!
[ *  *  *  *  * ]
Oh, right. Sorry, I assumed it was sarcasm :P

Oh, and Gorn, FF recognises ! important too.
Offline Profile Quote Post Goto Top
 
solinent
Member
[ *  *  * ]
Lol Firefox is getting smarter. I hope firefox doensn't adapt the * html thing cause then we're all gonna have to resort to SERVER SIDE scripting!!!! It's the apocalypse!!!(sarcastic there ;))
Offline Profile Quote Post Goto Top
 
Gornakle
Member
[ *  *  *  *  * ]
JoeC
June 14, 2005 01:48 AM
Oh, and Gorn, FF recognises ! important too.

It does, but IE doesn't (properly). In the following case:

Code:
 
div {
width: 20px !important;
width: 22px;
}


Firefox (and other browsers) use the 20px width because that was marked !important. IE uses the 22px width, ignoring !important.
Offline Profile Quote Post Goto Top
 
solinent
Member
[ *  *  * ]
Stupid IE <_<
Offline Profile Quote Post Goto Top
 
kragnerac
Member
[ * ]
solinent
June 15, 2005 12:51 PM
Stupid IE <_<

Stupid Avant... <_<
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Technology Chat · Next Topic »
Add Reply