# Part Two - CSS Hello, everyone! We continue the series of articles on developing a browser engine. Yes, better late than never. Yes, there was a long break. At the end of the article, I will describe how the lexbor project is doing and what is happening with it. In this article, I will try to delve into the peculiarities of parsing Cascading Style Sheets (CSS). I'll explain how to turn the "hedgehog" inside out and how to test the obtained result. Everything in CSS specifications is explained, well, almost everything. Here, I will tell you how everything is organized, where to look, and where to start. This article is more of an overview, and it won't delve into implementation details. Instead, it provides general information and basic algorithms. For the smallest implementation details, please refer to the GitHub code. And, of course, as usual, we will aim for the title of the fastest CSS parser. ## Where to Look? There are two sources for CSS specifications: 1. https://drafts.csswg.org/ – all drafts of the latest specifications. 2. https://www.w3.org/TR/ – the consortium that maintains "all" internet specifications. We will be working with [drafts.csswg.org](https://drafts.csswg.org/). It's concise, and each module has links to all versions of the module, from draft to recommended for use. ## How It's Organized? CSS is organized into modules: [Syntax](https://drafts.csswg.org/css-syntax-3/), [Namespaces](https://drafts.csswg.org/css-namespaces-3/), [Selectors](https://drafts.csswg.org/selectors-4/), [CSSOM](https://drafts.csswg.org/cssom-1/), [Values](https://drafts.csswg.org/css-values-4/), and so on. You can find a complete list on [csswg.org](https://drafts.csswg.org/). Each module, or rather its version, has a status: Working Draft, Candidate Recommendation, Recommendation, and so on. You can see all stages on [w3.org](https://www.w3.org/standards/types/). In simple terms, each module has a note: recommended for use, just started writing and it's unclear what will come of it, maybe we'll delete this module altogether, and so on, but more concise. We are interested only in Editor’s Draft and Working Draft with a glance at Recommendation. Honestly, W3 is a bit slow, and by the time they reach Recommendation (billions of stars will burn in space), everything will be outdated. In other words, we will treat CSS standards as living (living), just like the HTML standard. ## Let's Get Started with the Basics Of all the CSS modules, some are fundamental—without them, nothing works. This is the BASIS. 1. `Syntax` The [syntax module](https://drafts.csswg.org/css-syntax-3/) is the foundation. It describes the structure of CSS, the principles of token construction, and their subsequent parsing. 2. `Values` The [module describes](https://drafts.csswg.org/css-values/) the grammar. In all modules, we will encounter grammars and basic CSS types. For example, for the `width` property, the grammar looks like: ``` width = auto | | min-content | max-content | fit-content() ``` In addition, the module describes basic types and [mathematical functions](https://drafts.csswg.org/css-values-4/#calc-syntax): ``, ``, `