Skip to main content
D
CSS
CSS Syntax

CSS Syntax

CSS syntax connects styling rules to HTML elements.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

A CSS rule needs a selector and a declaration block. The selector targets the specific HTML element. The declaration block holds properties and values to style that element.

Syntax

Syntax
1/* css syntax */
2selector {
3  property: value;
4}

Try it Yourself

Hands-on Practice
Modify the code below to see how it affects the output. This is the best way to learn!
Interactive Editor
1234567891011121314151617181920
Live Preview

Key Points

  • The selector targets the HTML tag.
  • Curly braces surround the declaration block.
  • A colon separates properties and values.
  • Every declaration ends with a semicolon.

Up Next

Continue your journey with the next topic.

Go to CSS Selectors