Lesson 4: CSS Selectors
Have a Question?
Latest Articles

Lesson 4: CSS Selectors
CSS selectors are used to "find" (or select) the HTML elements you want to style. We can divide CSS selectors into five categories:
- Simple selectors (select elements based on name, id, class)
- Combinator selectors (select elements based on a specific relationship between them)
- Pseudo-class selectors (select elements based on a certain state)
- Pseudo-elements selectors (select and style a part of an element)
- Attribute selectors (select elements based on an attribute or attribute value)
Example :
/* The CSS element Selector */ p { text-align: center; color: red; }
/* The CSS id Selector */ #para1 { text-align: center; color: red; }
/* The CSS class Selector */ .center { text-align: center; color: red; }
/* The CSS Universal Selector */ * { text-align: center; color: red; }
/* The CSS Grouping Selector */ h1, h2, p { text-align: center; color: red; }
Important links About Us
Share with your friends