Formatting of dynamically generated HTML - does no one care?

前端 未结 13 1849
不知归路
不知归路 2021-01-11 17:10

I have very little experience in web development, so this may be a very basic question.

It\'s just, from the limited experience I do have (

13条回答
  •  温柔的废话
    2021-01-11 17:38

    Love it or not, HTML is a browser-readable format, not necessarily a user-readable one. Tools (WYSIWIG editors, markup languages such as Markdown, MediaWiki, etc. and your favorite web framework) should be used to used to generate HTML. Lots of programs are available to make HTML readable to developers; see the other posts.

    XHTML and XML-generating tools hold some promise as regards readability since their output can be post-processed more easily (by browsers' source view, for example) to obtain proper indentation, but (IMHO) aren't quite mature yet, judging by the number of so-called "W3C XHTML-compliant" websites that really aren't. Newer versions of, e.g., WordPress make an effort, but their extensions, plugins etc. are full of bad (X)HTML, not even considering the amount of JavaScript they produce. (How are we going to indent that?)

    Advice for now:

    1. (X)HTML-generating code should be readable for developers. But please do use one that at least generates something quasi-readable.
    2. Learn your browser's search function and use regexps.
    3. HTMLTidy, in its many guises, is your friend. Use it in tests and compare its input to its output

提交回复
热议问题