I found some CSS like this:
margin-top: ~"-2px\9";
Can anyone tell me what it is and what it does?
I found some CSS like this:
margin-top: ~"-2px\9";
Can anyone tell me what it is and what it does?
What is it?
A syntax error.
What does it do?
Breaks your stylesheet.
As mentioned in the comments on your question, it may be LESS instead of CSS. In LESS, a tilde before a string literal outputs the string as-is, because it may be a syntax error in pure LESS. \9
is an IE hack. See Escaping.
It may be a LESS Syntax. But tilde character is used in CSS3 as well. E-g the below Syntax:
p ~ ul { background:#ff0; }
will target ul elements that are preceded by a p element with the same parent:
In Less, this is called "Escaping".
Escaping allows you to use any random string as a property value or variable value.
For example ~"value" or ~'value' will be used as is without changes being made, only exception is interpolation.
Link to Less Docs: http://lesscss.org/#escaping