Is there an easier way to indent in HTML?

Is there an easier way to indent in HTML?
0

#1

I’m doing my technical documentation project and chose to explain HTML, but I want to have nested code when I show code. When I looked up how to indent online, people said the best way is to make a bunch of divs and add a margin-left to them in order to show indentation. I’ve done this so far, but it’s just a lot of code, kinda messy to me.

Is there an HTML symbol for indentation, like there is for an opening bracket (&lt) and a closing bracket (&gt)?


#2

You can use pre or code with white-space that keeps the tabs:

<pre>
  // level1
    // level 2
</pre>
<code style="white-space:pre">
   // level1
    // level 2 
</code>

#3

Thank you! This looks a lot better now


#4
&nbsp;

There are a few whitespace html entities
https://dev.w3.org/html5/html-author/charref


#5

Woooow

Thank you, I saved it to my bookmarks :+1: