11CSS basics
CSS Selectors
Easy20MIN
CSS selectors are crucial in defining styles. Selectors are used to choose HTML elements and apply desired style components to them. In the last module, we covered classes, but classes are just one of the numerous ways to select HTML elements in CSS. Here are a few common CSS selectors and their use cases:
Element selector
The element selector selects all occurrences of a specific HTML element. For example, the following code snippet selects all p elements and sets their text color to red:
CSS
1p {
2 color: red;
3}1 / 13
Hakatemia Pro
Learn to hack — start here
Hundreds of interactive courses, virtual labs and CTF challenges in your browser. Start a free trial — no card required.