tutorialstonight logo
A Platform To Learn To Code

CSS SYNTAX



The CSS syntax consists of a set of rules that directs how to apply it.

CSS rule have three parts:

  1. selector - selectors tells which element is to be styled.
  2. property - property defines the type of change or style we want.
  3. value - value provides information about what kind or how much change we want.
A single set of property and value is called a declaration.

CSS Syntax format

CSS Syntax

Example


To make properties and values more readable we can write like written below:

Example


Grouping selectors

In case you want to apply the same style for multiple selectors then it is not necessary to define CSS property for each selector. Just separate selectors with a comma and define only once.

Example

Run the code

Note: We will discuss all CSS property used above in further exercises.


CSS Property with multiple values

Some of the CSS properties have multiple sets of values which are mentioned at a time.Example:border property,shadow property,font property etc.

Example

Run the code



BOX

BOX