CSS MASTER CLASS /// LEARN SELECTORS /// TARGET ELEMENTS /// STYLING WEB /// CSS MASTER CLASS /// LEARN SELECTORS /// TARGET ELEMENTS /// STYLING WEB /// CSS MASTER CLASS /// LEARN SELECTORS /// TARGET ELEMENTS /// STYLING WEB ///

Basic Selectors

Learn how to find and hook into HTML elements. Master Classes, IDs, and Specificity logic.

style.css
1 / 11
12345
🎯

Tutor:CSS uses 'Selectors' to find (or select) the HTML elements you want to style. Without selectors, CSS wouldn't know where to apply the styles.


Skill Matrix

UNLOCK NODES BY LEARNING NEW SELECTORS.

Concept: Elements

Element selectors target raw HTML tags (like p or h1). They are very broad.

System Check

Which code snippet selects ALL paragraph tags?


Community Holo-Net

Showcase Your CSS

ACTIVE

Built a beautifully styled component? Share your CSS selector examples.

CSS Selectors

Author

Pascual Vila

Frontend Instructor // Code Syllabus

CSS Selectors are the hooks we use to grab HTML elements and style them. Without a selector, the browser wouldn't know which element should be red, big, or centered.

Element Selectors

Element selectors target HTML tags directly, like p, h1, or div. They are very broad and apply to every instance of that tag on the entire page.

Class Selectors

To target specific elements without affecting others of the same type, we use classes. A class selector starts with a period (.), for example .button. You can reuse the same class on multiple HTML elements.

ID Selectors

ID selectors are the most powerful basic selector. They start with a hash (#), like #header. An ID must be completely unique and only used once per HTML document. They beat Classes and Elements in the specificity wars.

Universal Selector

The Universal selector is represented by an asterisk (*). As its name implies, it targets every single element on the page. It's often used at the beginning of a CSS file to reset default browser margins and paddings.

Grouping Selectors

If you have multiple elements that share the exact same styling, you can group them using a comma (,). For example, h1, h2, h3 will apply the styles to all three heading levels. This keeps your CSS clean and DRY (Don't Repeat Yourself).

A Note on Specificity

When multiple rules target the same element, CSS uses Specificity to decide which rule wins. The hierarchy is strictly: IDs beat Classes, and Classes beat Elements. The Universal selector is the weakest of them all.

View Full Transcript+

This section contains the full detailed transcript of the video lessons for accessibility purposes. It covers the difference between Element, Class (.), and ID (#) selectors, and explains the concept of grouping multiple selectors separated by a comma.

Glossary

Selector
The part of the CSS rule that dictates exactly which HTML element(s) the styles should apply to.
Class (.)
A reusable selector prepended with a dot. Example: .card-title.
ID (#)
A strictly unique selector prepended with a hash. Example: #main-nav.
Universal (*)
A special selector (asterisk) that targets literally every element on the page.
Element (Tag)
Targets elements purely by their HTML tag name. Example: p, div, section. It has the lowest specificity weight.
Grouping ( , )
A comma used to separate multiple selectors, applying the same CSS rules to all of them simultaneously. Example: h1, .subtitle, #hero.
Specificity
The mathematical algorithm CSS uses to determine which CSS rule applies when there are conflicts. Hierarchy: ID > Class > Element.
DRY Principle
"Don't Repeat Yourself". A coding principle that grouping selectors helps achieve by reducing duplicated CSS rules.