CSS Syntax

Updated in 8th of June 2025

Programming or Coding

Think of CSS like giving your website a makeover.

But how does CSS know what to style and how?
That`s where CSS syntax comes in.


What is CSS Syntax?

CSS Syntax is the structure or format you use to write a style rule. It’s like a sentence that tells the browser what to style and how to style it.


The Basic Structure:





Let`s break id down:


  • h1 → This is the selector → it targets all <h1> headings
  • color → This is the property → what you`re changing
  • blue → This is the value → how you`re changing it
  • : → separates the property and value
  • ; → ends the line (important!)


Think of it like this:

Selector = Who?
Property = What?
Value = How?


More Examples:



 This styles all <p> (paragraph) elements by:

  • Making the text 18 pixels big
  • Centering the text
  • Changing the text color to green


Important Rules to Remember:


  1. Always use {} to open and close the style block
  2. Always end each line with a ; (semicolon)
  3. Don’t forget the colon : between property and value
  4. One selector can have multiple properties

Recap:



NEXT

Ways to Apply CSS to HTML

CONTINUE (2)

OTHER CONTENTS