DEV Community

Raj
Raj

Posted on

HTML CSS Selector

An HTML CSS Selector is a pattern used in CSS to target and select the specific HTML element(s) you want to style. It acts as the bridge between your HTML markup and your CSS styles.

1. What is the "Select All" Selector?
The "Select All" selector in CSS is known as the Universal Selector. It is written using an asterisk ().
Definition
The universal selector (
) matches every single HTML element on the page (or within a specific scope).
/* Selects ALL elements on the page */

  • { margin: 0; padding: 0; box-sizing: border-box; }

Common Use Case: It is most frequently used in CSS resets to clear default margins/paddings and set box-sizing: border-box globally across all elements.

2. Categories of CSS Selectors (With Examples)
CSS selectors fall into 5 main types:
Type 1: Basic Selectors

Type 2: Combinator Selectors
Combinators define the relationship between two or more selectors.
*** Descendant Selector (space)**: Matches all child/grandchild elements inside a parent.

Top comments (0)