CSS TutorialLesson 2Free preview
CSS Syntax
This lesson is part of CSS · All levels
Summary
Each CSS rule consists of two main parts: a selector that specifies the HTML element that you want to style, and a declaration block that contains one or more properties and their values. Properties and values are separated by a colon, and then each declaration ends with a semicolon. Multiple declarations may be combined into one block of the same declaration.
Key points
- The basic structure of CSS rules: selector {property: value;}.
- Properties determine the changed aspect (e.g. color), values determine the result (e.g. red).
- Declarations are separated by semicolons and the entire block is closed with curly braces.
- Spaces and new lines do not affect the way CSS is read, as long as the syntax is correct.
- A missing semicolon or curly brace error can cause one rule or many subsequent rules to fail.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.