Cascading Style Sheets (CSS) is an essential technology used in web development to style and layout web pages. CSS is not like other programming languages because of its unique core concepts and hence learning CSS can be challenging, especially for beginners. In this blog post, I attempt to outline how one can learn and master CSS.
Learning CSS can be broken down into 2 things: Learning and Practice
You need to learn 2 things in CSS: The core concepts & property-values.
Learning Core Concepts
This involves understanding the CSS specific concepts, theoretically. Things like cascade, z-index, box model, selectors etc
The resources I recommend for this are:
- web.dev guide - Super nice articles explaining each of the concepts in CSS. Must read!
- CSSBattles’s Learn CSS course - they just have a beginner course for now but it's a unique interactive game-like experience to understand the basics of CSS, while not feeling daunted with just reading long articles.
Learning about Properties and Values
The only resource I recommend here is the MDN docs. To learn properties and values, you should read the MDN docs on various properties. MDN docs provide an in-depth explanation of each property, including its syntax, possible values, interactive examples and browser support. As a routine, you can visit the MDN pages of the first 2-3 properties you use daily…its fun!
Once you get a basic knowledge about the core concepts and properties, practice is of utmost importance to turn your acquired knowledge into skills. Here are the 2 directions I recommend practicing CSS in:
- Page layouts by building pages - this is an excellent way to practice what you have learned. It will give you real-world experience in applying CSS concepts and properties to create practical layouts and structures. You can start with building static webpages - grab a design from Dribbble/Behance and turn into HTML & CSS. Then move onto building simple apps like a landing page or a portfolio website.
- Properties-values in CSSBattle - CSSBattle is a game where you play each level by replicating a given image as close as possible in just CSS in minimum number of characters (also called as code-golfing). Now writing minimum CSS may sound very impractical and it is! But you don't need to do code-golfing and can just focus on the matching the image part. Now even that might sound impractical, and yes that is! But suprisingly that gives you a very good practice in CSS properties and also helps develop your creative thinking when you come up with different approaches to replicate each level's image. There are so many levels on CSSBattle that doing them regularly will force you to experiment with each property and explore it in the process! I have personally learned a lot of properties here like clip-path, radial-gradient and much more.
In the end, the thing that will give the final sharpness to your CSS sword is - "The Specifications"! Specifications are the written documentation on each feature of CSS, by the people who build CSS! It covers every topic in-depth - upto details which then are also used by all the browsers to implement those CSS features. Reading these specifications give you the extra bit of understanding into why every features works the way it does.
Remember that learning and practicing are not sequential phases, they go hand-in-hand. Never stop learning as CSS language keeps evolving and so should your skills. And with time and practice, you can become a CSS master. Happy CSS-ing! 👋