codegurukool.com · Free coding tutorials & online compiler

Home › CSS Tutorial › CSS selectors

CSS selectors

Selectors choose which elements a rule styles.

A rule is selector { property: value; }. You can select by tag (p), class (.card) or id (#top).

Commands in this lesson

p

Definition: Defines a paragraph of text.

Syntax:

<p>Text</p>

Example:

<p>Hello, web!</p>

Example code

<style>
  p { color: teal; }
  .big { font-size: 28px; }
  #top { background: gold; }
</style>
<p>Teal paragraph</p>
<p class="big">Big paragraph</p>
<p id="top">Gold paragraph</p>

Run this code in the online editor

← All commandsCSS installation →