HTML CSS JavaScript SEO Python Posts Privacy About Contact

CSS Selectors

CSS selectors are used to find or select the HTML elements you want to style.

CSS selectors tell the browser which HTML elements to apply styles to. The three most essential selectors are the element, id, and class selectors.

Try It — All Three Selectors

Preview

Selector Reference

SelectorSyntaxTargets
Elementp { }All <p> elements on the page
ID#myId { }The one element with id="myId"
Class.myClass { }All elements with class="myClass"
Universal* { }Every single element on the page
Groupingh1, h2, p { }All h1, h2, and p elements together

Tip: IDs must be unique — one per page. Classes can be reused across many elements. Use classes for styles you want to apply to multiple things.