ArticleslgStudy

computer science

Less (style sheet language)

Less (style sheet language) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Less (style sheet language) rather than just read about it. In short: Less (Leaner Style Sheets; sometimes stylized as LESS) is a dynamic preprocessor style sheet language that can be compiled into Cascading Style Sheets (CSS) and run on the client side or server side. Designed by Alexis Sellier, Less is influenced by Sass and has influenced the newer "SCSS" syntax of Sass, which adapted its CSS-like block formatting syntax.

Less (style sheet language) — main illustration
Less (style sheet language) — illustration

Key takeaways

  • Less (style sheet language) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Less (style sheet language) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Less (style sheet language) from memory before moving on to harder problems.

Reference excerpt

Less (Leaner Style Sheets; sometimes stylized as LESS) is a dynamic preprocessor style sheet language that can be compiled into Cascading Style Sheets (CSS) and run on the client side or server side. Designed by Alexis Sellier, Less is influenced by Sass and has influenced the newer "SCSS" syntax of Sass, which adapted its CSS-like block formatting syntax. Less is an open source project. Its first version was written in Ruby; however, in the later versions, use of Ruby has been deprecated and replaced by JavaScript. The indented syntax of Less is a nested metalanguage, as valid CSS is valid Less code with the same semantics. Less provides the following mechanisms: variables, nesting, mixins, operators and functions; the main difference between Less and other CSS precompilers is that Less allows real-time compilation via less.js by the browser.

Features

Variables Less allows variables to be defined. Variables in Less are defined with an at sign (@). Variable assignment is done with a colon (:). During translation, the values of the variables are inserted into the output CSS document.

The code above in Less would compile to the following CSS code.

Mixins Mixins allows embedding all the properties of a class into another class by including the class name as one of its property, thus behaving as a sort of constant or variable. They can also behave like functions, and take arguments. CSS does not support Mixins: Any repeated code must be repeated in each location. Mixins allows for more efficient and clean code repetitions, as well as easier alteration of code.

The above code in Less would compile to the following CSS code:

Less has a special type of ruleset called parametric mixins which can be mixed in like classes, but accepts parameters.

The above code in Less would compile to the following CSS code:

Functions and operations Less allows operations and functions. Operations allow addition, subtraction, division and multiplication of property values and colors, which can be used to create complex relationships between properties. Functions map one-to-one with JavaScript code, allowing manipulation of values.

The above code in Less would compile to the following CSS code:

Comparison

Sass Both Sass and Less are CSS preprocessors, which allow writing clean CSS in a programming construct instead of static rules. Less is inspired by Sass. Sass was designed to both simplify and extend CSS, so things like curly braces were removed from the syntax. Less was designed to be as close to CSS as possible, and as a result existing CSS can be used as valid Less code. The newer versions of Sass also introduced a CSS-like syntax called SCSS (Sassy CSS).

Use on sites Less can be applied to sites in a number of ways. One option is to include the less.js JavaScript file to convert the code on-the-fly. The browser then renders the output CSS. Another option is to render the Less code into pure CSS and upload the CSS to a site. With this option no .less files are uploaded and the site does not need the less.js JavaScript converter.

Less software

See also Sass (style sheet language) Stylus (style sheet language)

References

External links Official website

Illustrations

Less (style sheet language) illustration

Worked examples

Example 1 — a first encounter with Less (style sheet language)

Start with the simplest possible case. Write down what Less (style sheet language) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Less (style sheet language) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Less (style sheet language) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Less (style sheet language)

In research
Less (style sheet language) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Less (style sheet language) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Less (style sheet language) is common in secondary-school and first-year university syllabi. It links to neighbouring topics 2009 software, Free computer libraries, JavaScript libraries, so understanding it makes those chapters shorter.
In everyday life
Look for Less (style sheet language) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Less (style sheet language) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Less (style sheet language) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Less (style sheet language) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Less (style sheet language) in simple terms?

Less (Leaner Style Sheets; sometimes stylized as LESS) is a dynamic preprocessor style sheet language that can be compiled into Cascading Style Sheets (CSS) and run on the client side or server side. Designed by Alexis Sellier, Less is influenced by Sass and has influenced the newer "SCSS" syntax o…

Why does Less (style sheet language) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Less (style sheet language)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Less (style sheet language).

Tags

  • 2009 software
  • Free computer libraries
  • JavaScript libraries
  • Software using the Apache license
  • Stylesheet languages

Keep exploring