HTML Introduction to HTML and CSS Adding a New Web Page Write the CSS

Andrea Fenwick
Andrea Fenwick
443 Points

Indentions

Is there a method when determining the level of indention used? For example, when writing CSS for body and .main-image, Treasure seems to indent each line. Once I hit enter to write on a new line, can I simply begin writing or is it best practice to always indent so many characters?

1 Answer

Podrig Leoghain
Podrig Leoghain
5,087 Points

In HTML and CSS indentation is for readability. So yes you could just type away and nothing bad would happen when you use it (if the code is correct, of course). However, it might not be as easy to read after writing e.g. 50 lines of CSS.

I believe JavaScript uses the same indentation so don't worry about getting it wrong.

Andrea Fenwick
Andrea Fenwick
443 Points

Awesome, so essentially it is personal preference if I choose to indent each block once or twice with HTML or CSS. Appreciate the clarification!

Podrig Leoghain
Podrig Leoghain
5,087 Points

No problems, happy to answer your question.

Podrig Leoghain
Podrig Leoghain
5,087 Points

(Feel free to mark the best answer!)