O'Reilly logo

Less Web Development Essentials by Bass Jobsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Escaping values

Less is an extension of CSS. This means that Less gives an error when it comes across invalid CSS or evaluates a valid CSS during compilation. Some browsers define properties with an invalid CSS. Well-known examples will include something such as property: ms:somefunction(). Some of these rules can be replaced by vendor-specific rules. It is important to note that invalid property values won't get compiled in Less.

A new function, calc(), in CSS3 is a native CSS way of doing simple math as a replacement for a value of any length.

In both cases, Less won't give us the right value when we compile or import.

@aside-width: 80px;
.content {
width: calc(100% -  @aside-width)
}

The preceding code gets compiled into the following code:

.content ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required