Constants: @constant
Allows authors to define a one or more values that cannot be changed while the stylesheet is parsed. Unlike variables, constants do not have to begin with a dollar-sign ($). Also unlike variables, constants have no scope, they are considered global and can be used anywhere.
@constant BODY_BACKGROUND_COLOR: #fff;
.container {
background-color: BODY_BACKGROUND_COLOR;
}
.container {
background-color: #fff;
}
For clarity, authors should define constants with names in all-caps. While constants do not have to begin with $, authors may wish to do so as some constant names can cause unexpected results!
@constant 1px: 10em;
.unexpected {
border: 1px solid #f00;
}
.unexpected {
border: 10em solid #f00;
}
If a constant is declared again or an attempt is made to give it a different value, the parser will ignore the request and continue processing the stylesheet. However, a parser may add a comment to the stylesheet or provide another indication that a invalid request was made.