Sass and less are an extension of CSS, which itself cannot replace CSS, but it can help us simplify the code and do more with fewer code.
Less and sass have some grammatical commonalities, such as the following:
- Mix the class in the (Mixins)--class;
- Parameters are mixed--the class that can pass the parameter, just like a function;
- Nested rules are nested in the--class class, thus reducing duplication of code;
- Mathematics is used in the arithmetic--css;
- Color function--can edit color;
- Namespaces (namespace)--grouping styles, which can be called;
- Scope-local modification style;
- JavaScript assignment-use JavaScript expressions to assign values in CSS.
(1) One of the major differences between sass and less is that less is JavaScript-based and is processed on the client side, while Sass is based on Ruby and is processed on the server. Many developers don't choose less because the JavaScript engine takes extra time to process the code and then output the modified CSS to the browser.
(2) Sass and less are also significantly different in variable scope. Less has global variables, and sass temporarily does not have the concept of global variables.
(3) The point that sass is more perfect than less is that sass can edit functions by @function, loop the data through @for loops or @each loops, and judge the data by @if else.
Discussion on the difference between sass and less