When do you use 2 space indentation?

Hi guys, im just starting to learn coding. Seems confusing. Just a question, when do you use 2 space indentation
Should it be like this:

<body>
  <h1>The Brown Bear</h1>
  <div id="introduction">
    <h2>About Brown Bears</h2>
    <p>“The brown bear (Ursus arctos) is native to parts of northern Eurasia and North America. Its conservation status is currently Least Concern. There are many subspecies within the brown bear species, including the Atlas bear and the Himalayan brown bear.”</p>
    <h3>Species</h3>
    <h3>Features</h3>
    <p>“Brown bears are not always completely brown. Some can be reddish or yellowish. They have very large, curved claws and huge paws. Male brown bears are often 30% larger than female brown bears. They can range from 5 feet to 9 feet from head to toe.”</p>
  </div>

or 

<body>
  <h1>The Brown Bear</h1>
  <div id="introduction">
    <h2>About Brown Bears</h2>
      <p>“The brown bear (Ursus arctos) is native to parts of northern Eurasia and North America. Its conservation status is currently Least Concern. There are many subspecies within the brown bear species, including the Atlas bear and the Himalayan brown bear.”</p>
    <h3>Species</h3>
    <h3>Features</h3>
      <p>“Brown bears are not always completely brown. Some can be reddish or yellowish. They have very large, curved claws and huge paws. Male brown bears are often 30% larger than female brown bears. They can range from 5 feet to 9 feet from head to toe.”</p>
  </div>

can we indent everything to nest?

Short version: indent everything you’re nesting for readability.

Long version: indenting is a big point of contention with coders. Some people use two or four spaces, and some people use tabs. Python requires spaces, so particularly if you’ve learned python first, you might use two spaces. Four is probably more common.

I always use tabs, and here’s why: https://www.reddit.com/r/javascript/comments/c8drjo/nobody_talks_about_the_real_reason_to_use_tabs/

It’s basically an accessibility issue.

Sooner or later you’ll be working on a team, and that team will probably have a style guide. Most likely that will include whether you use tabs or spaces.

3 Likes

I formatted the HTML that you posted so that the code is visible here on the forums.

Take a look at this post for more info on how this works. :slight_smile:

1 Like

Thank you. The platform seems confusing to me. Is there a video tutorial on how to use it? :slight_smile: