PDA

View Full Version : really useful CSS trick for IE and FF



jl9148
Nov 18th, 2006, 05:26 AM
for some reason, i found a trick/hack in stylesheets; acutally im not sure if this has already been found out but anyways...
it can display codes in IE or in FF, which ever you want, (kind of similar to the * html trick)

i found this trick by accident, trying to code a layout and checking if it looks good on both browsers.

my css..



#blah2
{
// margin: 0px; <--- does not display in FF, but still displays in IE (IE ignores the // )
}

i think you have to put an indent/[tab] between the // and the attribute

that thats my code, im not sure if it works for all types of attributes, but thats what happened to me.

so yeah, this isnt really a 'help me' thread, but just letting you guys know if anyone would want to test this out.

oh also, i am using FFv2 and IE7

i have provided an example here http://www.freewebs.com/jl9148/test.htm, please test the page in both FF and IE


edit: i have tested the code in all types and versions of FF and IE, and i get the same result

harbingerOTV
Nov 18th, 2006, 06:39 AM
really intresting. havent had to use hacks for some time (save for opera) but i plyed with it and tried to make it choke. the tab doesnt sem crucial. i found this as well:

http://www.cyclomedia.co.uk/?9

if it seems a more univerasa/l hack, cool.

ahallicks
Nov 18th, 2006, 09:13 PM
Or for IE you could simply use one / before any line of CSS. For example:




#blah {
padding-left: 20px;
/padding-left: 10px;
}



This will pad it 20px on the left in Firefox and 10px in IE. I've used this hack for a while now and it works a treat when you have to pad something as quite often IE and Firefox display the padding slightly differently and it is a godsend!