5

I inherited a CSS style sheet, 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;

What is that forward slash doing?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
jpw
  • 18,697
  • 25
  • 111
  • 187
  • That's one hack I've never encountered. But CSS3-specific? Nah. It's not even valid CSS. Retagged. – BoltClock Apr 26 '11 at 18:44
  • Never seen that either. I know `_margin: ...` for IE6 and `*margin: ...` for IE7. It's definitely not correct CSS syntax =) – Rudie Apr 26 '11 at 18:50
  • 1
    @Rudie: It's `_` for IE6 and `*` for IE6/7. – BoltClock Apr 26 '11 at 18:52
  • 1
    @BoltClock Oops, my bad. (I edited for safety..) I don't use either anymore. If you're using IE < 8, you don't deserve internet. – Rudie Apr 26 '11 at 18:54

1 Answers1

7

It's to target LTE IE7. This hack isn't known as much as the IE6 underscore one.

    #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 make the backslash almost anything you want really, expect the underscore _ as that will target IE6. I use the $ personally.

EDIT:
I've included the IE6 trick too there, as anything IE7 and below will take the / property unless you also have an _ property too.

To target IE8, IE7, and IE6 you need to have that order above.

Knu
  • 14,806
  • 5
  • 56
  • 89
Nathaniel B
  • 145
  • 6