About this lesson
Download this lesson’s exercise file.CSS Syntax.docx
CSS Syntax is made up of selectors and declarations.
When to use
Any time you write CSS code, you're write a selector followed by a declaration.
Create a new syles.css file to write all of your CSS.
CSS syntax is pretty straight forward. It's made up of a selector, followed by a declaration (curly braces). The selector says what the thing is and the declaration says what you want to do with it.
All of your CSS will go inside of your curly braces or the declaration.
Inside the declaration we have a property and a value. Properties end in colons, values end in semi-colons.
You can have as many sets of property and values inside your declaration as you like.
Hints & tips
- CSS Syntax is made up of selectors and declarations
- Declarations are made up of properties and values
- Properties end in colons
- Values end in semi-colons
- Best practice is to put each property / value on its own line
- Adding comments in the CSS is beneficial expecially in longer CSS files
Lesson notes are only available for subscribers.