CSS Syntax

CSS rules consist of two main parts: selectors, and one or more declarations:

Selectors are usually HTML elements that you need to change styles.

Each declaration consists of an attribute and a value.

The property is the style attribute you want to set. Each attribute has a value. Attributes and values ​​are separated by colons.

CSS examples

CSS declarations always end with a semicolon (;), and declarations are always enclosed in curly braces ({}):

p {color:red;text-align:center;}

To make CSS more readable, you can describe only one attribute per line:



CSS comments

Comments are used to explain your code, and you can edit it at will, the browser will ignore it.

CSS comments start with /* and end with */ , examples are as follows:

/* This is a comment */ p { text-align: center

     /* This is another comment */ color: black