🌱 Digital Garden

Search

Search IconIcon to open search

CSS Basic Syntax

Last updated Aug 5, 2023 Edit Source

# Syntax

CSS has its own syntax rules. The most Basic CSS syntax consists of a list of parameters. Like follows:

1
selector { property: value; }

It consits of two key parts:

# Examples

1
2
3
4
5
6
7
8
9
h1 {
  color: red;
}

div, p {
  width: 500px;
  height: 50px;
  color: yellow;
}

Each declaration block its divided in parts, property name and value, each separated by a colon.

# Comments

The syntax of CSS comments is like a multi line comment in java:

1
/* THIS TEXT IS COMMENTED */

# Single Line comments

1
2
3
p {
  color: blue; /* the color of the text paragraph is blue */
}

# Multi-line comments

1
2
3
4
5
6
7
8
/* The styles given
   to the paragraph
   with the text 
*/
p {
  color: blue;
  background-color: black;
}

They can let u disable code fragments, to be honest, its like using multi line java comments for everything.