Slash in CSS? Is this some kind of feature in the browser?

I inherited the CSS stylesheet, and in a few places it does things like:

margin:7px 0 0 0;
/margin-top:9px;

or

background: url(../images/list-hover.png) 0 0 no-repeat;
/background:url(../images/lists-hover.png) 0 2px no-repeat;

Does anyone know what this slash does?

+5
source share
1 answer

It is designed for LTE IE7. This hack is not as well known as IE6 underscore.

    #myelement {
background:red; /*Should show as red in all browsers, expect IE6 and IE7 because...*/
/background:yellow; /*IE7 should have yellow*/
_background:green; /*IE6 should have green*/
}

You can do the backslash with almost anything you want, and expect the underscore to _, as this will target IE6. I use $ personally.

EDIT:
I also included the IE6 trick, since something IE7 and below will accept the / property if you also don't have the _ property.

To target IE8, IE7, and IE6, you must have this order above.

+7

All Articles