</> Code Corner

CSS · CSS Tutorial · Lesson 2

CSS Syntax

Selectors, properties and values.

A CSS rule consists of a selector and a declaration block.

Example

<style>
p {
  color: red;
  text-align: center;
}
</style>
<p>Hello World!</p>
<p>These paragraphs are styled with CSS.</p>
  • p is the selector — it points to the HTML element to style
  • color is a property and red is its value
  • Each declaration ends with a semicolon, and blocks are surrounded by curly braces

Keep reading “CSS Syntax”

Sign up to read the full lesson, try every example in the live editor, and take the 5-question quiz.

Chat with us 👋