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

Namespacing in Less


There is one thing I am sure you will find asking yourself as time goes by and your CSS style sheets get larger: can I group similar styles to make things easier to find?

Sure, you can always cut and paste similar styles together, but this is a manual process, right? What happens if two weeks down the line, you need to add a new style, which is similar to the one buried 1500-odd lines down? Surely there has to be a better way to do this—there is. Welcome to namespacing in Less!

Namespacing in Less takes your need to group similar styles and flips it on its head; it groups all of the constituent building blocks of your styles together, then allows you to pick and choose which styles to use when adding styling for a new element on your site. We can, of course, create multiple namespaces if we need to—our only real guide for this is that each namespace should contain styles that share common elements; a great example is buttons, as you will see from our upcoming exercise...