Hongmu Notes

⌨️ HTML formatting

Paste the HTML source code and rearrange it according to the selected indentation unit, leaving the original content unchanged.

HTML formatting

Instructions for use

  • First select the indentation unit, then paste the HTML and click "Start Processing"
  • Keep scripts, styles and comments as they are, only adjust the indentation
  • Formatting is done using local libraries, and the code will not be uploaded to the server.

HTML two space indent

HTML with a deep hierarchy can easily push to the right side of the screen with 4 spaces. Changing it to 2 spaces can not only show the hierarchy but also maintain the line width.

📌 Are 2 spaces enough to see the hierarchy?

Enough. The core of indentation is "equal width increment for each level". Two spaces can also express nesting relationships; for deeply nested tables and lists, the advantage of line width is more obvious.

📌 Indentation rules

Formatting determines indentation based on the nesting level of tags: each time a sub-element is entered, one indentation unit is added, and when a closed tag is encountered, it is returned one level; text nodes and inline tags will not be forcibly split, so short fragments will remain compact, and tag attributes and text content will not be rewritten.

🧭 Common uses

Viewing the compressed template source code, sorting out the fragments copied from the web page, checking the email template structure, and changing the HTML returned by the interface back to readable layout, it is most labor-saving to format the code first and then analyze it; the results and input are displayed separately, which facilitates left and right comparison, and the change in the number of lines before and after formatting can also intuitively reflect the nesting depth.

All keywords and tutorials 12

❓ FAQ

Will it affect operation?
No. Indentation only affects readability and has nothing to do with the running of the page.
Can it be changed to tab character?
Yes. Just select "Tab indentation" from the drop-down menu.
Why 2 spaces are commonly used
It can maintain better line width in narrow screens, narrow columns and code review tools, making reading easier.