Book Image

Learning less.js

Book Image

Learning less.js

Overview of this book

Table of Contents (22 chapters)
Learning Less.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 5. Inheritance, Overriding, and Nesting in Less

So far in our journey with Less, we've seen how you can begin to reduce the code you need to write; it's time to take it up a level and begin to look at some more advanced concepts within Less.

Let me begin by asking you a question: what is the one thing that irritates you about writing styles where the same selector has to be repeated many times, such as when designing a menu system using an unordered list element? Hopefully, the answer is duplicated styles. In this chapter, we will take a look at how you can group styles to avoid the need to duplicate selectors in your code. We will also cover how you can inherit styles that can have a dramatic effect on reducing duplication; I'll also provide some hints and tips on using these techniques and others to help reduce code bloat.

Enough chat, let's take a look at what we will cover throughout this chapter:

  • Nesting styles within Less

  • Inheriting styles

  • Namespacing in Less

  • Scope of styles in Less...