How do I format my markup?

When it comes to my markup, I am anal. It should always be perfect indentation, easy to read for me, and 100% valid with W3C. Often, while browsing the markup of other websites, I am horrified by the lack of developer efforts to try and keep my markup in the browser clean, organized, and reliable.

On the other hand, there are many people who will force all their marking into one continuous line for the benefits of size savings. It annoys me too, although not so, because it is being done for a specific purpose. But for the most part, it seems that no developer ever looks at his markup in a browser and does nothing.

Understanding that for a parser in a browser, indents and spaces (usually) doesn’t matter, how do I handle my markup? Is it worth the extra time to make my markup easy to understand for people as well as for the browser? All tags \tand \nused in vain?

+3
source share
6 answers

This is worth the effort of imho, as it helps you understand what exactly is happening on your html page, and it is definitely worth it.

If we want to write clean, elegant code in general, does this mean that we must also generate beautiful, clean, elegant HTML code, and not?

+1
source

, , html . , Internet Explorer .

, , , , .

+3

, .

. :

  • , , , , (, Netbeans). , .
  • , .
  • , HTML, Tidy ( Tidy Firefox) .
  • : + ( , ) . .
+2

, , , W3C, . (, ), , ( ..). DOCTYPE , . " " , "" . , , .

+1

, , , .

ASP.NET, . , , - , .

, , .

+1

, . , , .

About the lack of lower performance, why not develop a well-deferred and commented out source file and create a version with a minimal version to run on the server? This can be achieved with a simple series of regular expressions.

+1
source

Source: https://habr.com/ru/post/1788048/