Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Enduring CSS

You're reading from   Enduring CSS Create robust and scalable CSS for any size web project

Arrow left icon
Product type Paperback
Published in Jan 2017
Publisher Packt
ISBN-13 9781787282803
Length 134 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Ben Frain Ben Frain
Author Profile Icon Ben Frain
Ben Frain
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Enduring CSS
Credits
About the Author
Thanks
www.PacktPub.com
Preface
1. Writing Styles for Rapidly Changing, Long-lived Projects FREE CHAPTER 2. The Problems of CSS at Scale 3. Implementing Received Wisdom 4. Introducing the ECSS Methodology 5. File Organisation and Naming Conventions 6. Dealing with State Changes in ECSS 7. Applying ECSS to Your Website or Application 8. The Ten Commandments of Sane Style Sheets 9. Tooling for an ECSS Approach 1. CSS Selector Performance 2. Browser Representatives on CSS Performance

2. Thou shalt not nest, unless thou art nesting media queries or overrides


The key selector in CSS is the rightmost selector in any rule. It is the selector upon which the enclosed property/values are applied.

We want our CSS rules to be as flat as possible. We DO NOT want other selectors before a key selector (or any DOM element) unless we absolutely need them to override the default key selector styles.

The reason being that adding additional selectors and using element types (for example h1.yes-This_Selector):

  • Creates additional unneeded specificity

  • Makes it harder to maintain, as subsequent overrides need to be ever more specific

  • Adds unneeded bloat to the resultant CSS file

  • In the case of element types, ties the rule to a specific element and/or markup structure

For example, suppose we have a CSS rule like this:



   #notMe .or-me [data-thing="nope"] .yes-This_Selector {
       width: 100%;  
   }

In that above example, yes-This_Selector is the key selector. If those property/values should...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images