Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

forward slash in CSS? Is this some browser specific thing?

Tags:

css

css-hack

I inherited a 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;

anyone know what that forward slash is doing?

like image 327
jpw Avatar asked Apr 26 '11 18:04

jpw


People also ask

What is forward slash in CSS?

The forward slash is required syntax for separating background position values and background size values. This is to eliminate misinterpretation of the values specified. If you're going to specify both, then background-position has to come first, then the forward slash, then the background-size.

What does the forward slash in HTML indicate?

In most cases, the tag is repeated at the end of the content, with the tag name preceded by a forward slash (e.g. </p>), to indicate that the action is no longer needed.

What does forward slash looks like?

Also, you may know their differences. The easy way to remember them is that a backslash is a backward lean (\) while a forward slash leans forward (/).

What slash is used in URL?

A trailing slash is a forward slash (“/”) placed at the end of a URL such as domain.com/ or domain.com/page/. The trailing slash is generally used to distinguish a directory which has the trailing slash from a file that does not have the trailing slash.


1 Answers

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.

like image 89
Nathaniel B Avatar answered Sep 23 '22 12:09

Nathaniel B