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 four space indent

4 spaces is the most common indentation unit: the hierarchical gap is large, the contrast is obvious, and the nesting relationship is easier to see when casting or printing.

📌 Would 4 spaces be too wide?

It is just right for structures within three levels; if the nesting is very deep, you can use 2 spaces or tabs instead to avoid each line being indented and taking up too much width.

🧭 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.

🔒 Dealing with location and privacy

Formatting is completed using a local library loaded with the page, and the code is not uploaded to the server or written to local storage; page fragments and email templates from the internal system can be pasted with confidence, and the page will be cleared after the processing is completed, leaving no cached copies.

All keywords and tutorials 12

❓ FAQ

Can it be mixed with tab characters?
Not recommended. Only by unifying the units can the layout be consistent. This page is only formatted one unit at a time.
Can it be used in other languages?
js-beautify supports multiple syntaxes, but this page is targeted at HTML scenarios.
When to choose 4 spaces
When the structure is not deep and needs to be printed or projected onto the screen for explanation, the hierarchical comparison of four spaces is the most intuitive.