CSS SELECTORS EXAMPLES

Universal Selector (*)

This is affected by the universal selector.

Type Selector (h1, p)

This paragraph is styled using type selector.

Class Selector (.note)

This paragraph uses a class selector.

ID Selector (#intro)

This paragraph uses an ID selector.

Child Selector (div > p)

This paragraph is a direct child of div.

This paragraph is inside section (not styled).

Descendant Selector (div p)

This paragraph is a descendant of div.

This one is also a descendant.

Adjacent Sibling Selector (h2 + p)

This paragraph comes immediately after an h2 tag.

General Sibling Selector (h2 ~ p)

This paragraph is a sibling of h2 tag.

This is also styled using general sibling selector.