Revisiting your code to remove redundancies and inconsistencies—known as refactoring—is a common practice when using programming languages. With this book, author Steve Lindstrom not only shows you how to structure your CSS to build a responsive, easy-to-use website, but also how to use refactoring tools to create faster, more readable CSS.
Discover why CSS is easy to learn but difficult to master
Understand the difference between good and bad CSS
Learn about refactoring and how it relates to CSS
Explore methods for executing a CSS refactoring
Learn how to deal with browser inconsistencies
Investigate common CSS antipatterns—and how to avoid them
Use techniques for structuring a project's CSS
Recognize when your CSS refactoring is successful
Chapter 1Refactoring and Architecture
What Is Refactoring?
What Is Software Architecture?
Shortcomings that Lead to Refactoring
When Should Code Be Refactored?
When Should Code NOT Be Refactored?
Am I Allowed to Refactor My Code?
Chapter 2Understanding the Cascade
What Is the Cascade?
Inline CSS and Specificity
Overriding the Cascade with the !important Declaration
Chapter 3Writing Better CSS
Consistently Structure Rulesets
Keep Selectors Simple
Assign Classes Meaningful Names
Build a Better Box
Chapter 4Classifying Different Types of Styles
The Importance of Classifying Styles
Why Is Testing Difficult?
Which Browsers Are Important to Test?
Browser Market Share
Testing with Multiple Browsers
Testing with Old Versions of Browsers
Testing the Bleeding Edge
Third-Party Testing Services
Testing with Developer Tools
Visual Regression Testing
Maintaining Your Code
Chapter 6Code Placement and Refactoring Strategies
Organize CSS from Least Specific to Most Specific Styles
Multiple Files or One Big File?
Auditing Your CSS Before Refactoring
Safari Books Online
Early Release Ebook
Early Release Ebook:
| ISBN 10:
Early Release Ebook ISBN:
| ISBN 10:
Steve Lindstrom has been building websites since 1999 when he built his first as a hobby in middle school. Since then he has earned his BS in Computer Science at the Florida Institute of Technology in Melbourne, Florida. Steve has written software while working in the defense, travel-tech, and most recently e-commerce industries. When he's not in front of a computer he enjoys learning to cook and drinking coffee.
The animal on the cover of CSS Refactoring is an African palm civet (Nandinia binotata), also called the two-spotted palm civet. This is a small omnivorous mammal closely related to the weasel and mongoose. Most of the palm civet's range is in eastern Africa, but it has also been found in central and western regions of the continent. It prefers a habitat of lowland forests or tropical jungles.
The African palm civet has short legs, a long tail, and tan fur mottled with darker spots. It somewhat resembles the domestic cat, moreso than other civet species, and so it is the only member of the Nandinia genus. On average, they weigh between 3 to 5 pounds. This is a solitary animal that spends most daylight hours resting in the safety of a tree. At night, it emerges to eat: while the civet's diet is largely made up of fruit, it also hunts insects, lizards, birds, bats, and small rodents.
African palm civets breed twice a year, in May and October (these are times when more food is usually available). After her litter is born, the mother's mammary glands produce an orange-yellow liquid that stains both her belly and her offspring's fur. The purpose of this is not entirely clear, though it could signal that she is not available to mate and/or warn off males who may try to harm her young.
Civet is also the name of the musk these animals excrete to mark their territory and find mates. Diluted, it has been used as a perfume ingredient for centuries. A synthetic version is used in many modern products, but several species of civet are still illegally trapped for their meat and scent glands.
Many of the animals on O'Reilly covers are endangered; all of them are important to the world. To learn more about how you can help, go to animals.oreilly.com.The cover image is from Lydekker's Royal Natural History.