Steven Lambert
Steven Lambert

Reputation: 5921

Stylus keep "\9" CSS IE9 hack

I'm trying to write an IE9 rule only (width: 40px\9;) in Stylus, but it seems that Stylus keeps removing the \9 part and turns it into a whitespace character instead. I've tried various combinations of \ and /, but to no avail.

For example

width 40px\\9;

compiles to

width: 40px \ 9;

Does anyone know how to make stylus keep the \ as a literal "\" and not turn it into a whitespace?

Upvotes: 1

Views: 1034

Answers (2)

Sampson
Sampson

Reputation: 268482

This approach does not only apply to Internet Explorer 9; this hack affects also Internet Explorer 8, and 10. These three versions of Internet Explorer doesn't require the same solutions to certain layout problems, and as a result, this approach is likely to create more problems than it solves.

Microsoft has provided a method for applying browser-specific styles via the use of conditional comments. This is the means by which you should do browser-specific alteration is needed — please avoid CSS hacks.

To target Internet Explorer 9, use the following conditional comments:

<!--[if IE 9]>
    <link rel="stylesheet" href="ie9fixes.css" />
<![endif]-->

Although the above will likely help you resolve your issue more quickly, the correct approach is to ensure that a workaround is even necessary. Make sure that your markup and CSS are valid. More often than not browser-specific problems are the result of invalid code.

Support for conditional comments was dropped in Internet Explorer 10.

Upvotes: -1

dinocarl
dinocarl

Reputation: 728

You need to use unquote:

width unquote('40px\9')

yields

width: 40px\9;

Upvotes: 2

Related Questions