Sublime Forum

Indent head and body tags

#1

I’d like autoformatting to indent the head and body tags one step in from the html tags. Right now if I hilight the whole document, then go to Edit > Line > Reindent, I get this:

<html>
<head>
	<title></title>
</head>
<body>
	Awesome content here
</body>
</html>

…and I’d like to get this:

<html>
	<head>
		<title></title>
	</head>
	<body>
		Awesome content here
	</body>
</html>

I’ve searched all over and can’t figure out how to do this.

Thanks in advance for you help!!!

1 Like

#2

I have the same problem. Finally, found someone like me. I don’t understand why would they choose not to indent <head> and <body> tags.

0 Likes

#3

Because it common practice used by most formatters and there’s little to no value in adding another indentation level.

The <html> root node contains only those two <head> and <body> children which take the main content. As it is indented, finding start and end of them should be easy enough.

<html>
<head>
    <title>Title</title>
</head>
<body>
    <p>Content</p>
</body>
</html>
0 Likes