i

Learn HTML and CSS in 10 Days

Write CSS Using Multiple Lines and Spaces

While dealing with CSS, it is recommended to keep each declaration and selector on a new line. Then, inside each of the selectors, we need to provide indentation to our declarations.

Before the 1st declaration and after the selector comes the {, opening curly bracket, which needs to have space just before it. Inside each declaration, it is important to put a space after the colon, :, that follows a property and terminates each declaration using a semicolon, ;.

Performing it makes the program code easy to read and edit. When all the CSS code is placed into a single line without providing any space, it becomes hard to scan and edit them.

Bad Code

a,.btn{background:#bbb;color:#f64;font-size:20px;padding:5px;}

Good Code

a,

.btn {

  background: #bbb;

  color: #f64;

  font-size: 20px;

  padding: 5px;

}