Skip to content
techsnow

Introduction

CSS Syntax

A CSS file is a list of rules. Each rule has a selector and a declaration block.

Syntax:

selector {
  property: value;
  property: value;
}
PartExampleMeaning
SelectorpWhich elements to style
PropertycolorWhat to change
ValueredHow to change it
Declarationcolor: red;One property + value, ending with a semicolon
p {
  color: #333;
  font-size: 18px;
  line-height: 1.6;
}

Comments

/* This is a CSS comment */
p { color: gray; } /* comments can go at the end of a line too */