CSS
CSS SyntaxCSS Syntax
CSS syntax connects styling rules to HTML elements.
Read Time
5 min readDifficulty
BeginnerLast Updated
Jun 15, 2026Version
v1.0.0Introduction
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
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.