Syntax - Tasty Web Development Treats
Syntax - Tasty Web Development Treats

Hasty Treat - Tips For Writing Good CSS

In this Hasty Treat, Scott and Wes talk about tips for writing good CSS. Sizzy - Sponsor Sizzy - The browser made for developers and designers. Stop manually resizing your browser window and switching between devices so you can test responsive design. Speed up your workflow by developing and preview

Featured Speakers

Wes Bos & Scott Tolinski - Full Stack JavaScript Web Developers Host

Topics Discussed

Episode Summary

Executive Summary: The episode focuses on practical principles for writing maintainable CSS: build and follow a system, embrace the cascade and scoping when appropriate, define typography early, use meaningful names, avoid overusing element selectors and !important, and keep CSS organized and revisable as projects evolve. The hosts frame CSS as something that improves with consistency, conventions, and real-world experience.

Main Topics: Use a CSS system: The hosts stress that the most important habit is to establish a clear system for writing CSS so teams can stay consistent and avoid reinventing patterns. Embrace the cascade and scoping: They argue that good CSS balances broad reusable styles with scoped overrides, and that understanding specificity is essential to avoid debugging pain. Define typography early: Typography is presented as a foundational global decision that should be set early and revisited when the system no longer fits project needs. Choose a naming and architecture pattern: They discuss BEM, CSS-in-JS, functional CSS, and other approaches, emphasizing that the pattern matters less than having one and using it consistently. Use semantic, meaningful names: The hosts recommend naming classes by purpose or role rather than appearance, so styles remain accurate even when design changes. Organize and maintain CSS over time: They advise grouping related styles, commenting hacks clearly, removing dead code, and treating CSS as an evolving system rather than a fixed artifact.

Key Arguments: A shared CSS system reduces guesswork and helps teams extend styles consistently instead of inventing ad hoc solutions. The cascade is a core strength of CSS and should be used deliberately rather than avoided, but overly broad rules can create debugging problems. Scoping is valuable because CSS is global by default; limiting styles to a component or section prevents accidental leakage. Typography should be established early because repeatedly overriding font sizes, families, and spacing signals a weak design system. BEM and similar methodologies are useful mainly because they impose structure, not because their syntax is inherently superior. Element selectors are fine in narrowly scoped contexts, but broad global styling should generally be class-based and semantic. Meaningful names such as 'warning' or 'playlist' age better than appearance-based names like 'red' or 'big green text' because design can change. CSS should be organized into chunks or files, with comments that explain unusual decisions and with dead code removed when no longer used.

Data Points: Sponsor price: $5/month - Sizey solo plan mentioned in the sponsor read Device examples: iPhone, Pixel phone, iPhone X - Examples of synchronized device windows in Sizey Heading custom properties: 9 - One speaker described maintaining nine heading size variables, including heading 7 CSS tip count: Multiple tips (no exact total stated) - The episode presents a list of CSS best practices rather than a quantified study

Pivotal Quotes: "“We just want to say that we love CSS, and we want to talk a little bit about how to write good CSS.”" — Scott Tolinsky: Sets the episode’s positive framing around CSS and maintainability "“Embrace the cascade.”" — Wes Bos: Core principle used to explain how CSS should be organized and overridden "“The most important part isn’t the syntax. What’s important is that simply, there is a system.”" — Wes Bos: Explains why BEM and other methodologies matter mainly as structured systems

Implications: Listeners are encouraged to treat CSS as a design system problem: standardize conventions, write for change, and use scoping and naming to reduce future maintenance costs. This approach should improve team consistency and long-term scalability.

🔓 Sign Up for Unlimited Episode Search

About Syntax - Tasty Web Development Treats

View all episodes from Syntax - Tasty Web Development Treats