Tidy 23

From Htmlpedia
Jump to: navigation, search

Tidy: Trimming Empty Tag


An element is empty or only contains white space (newlines, spaces, or tabs). This issue may be the side effect of a tag being implicitly closed by another.


Bad<p> </p>
Good<p>This is a paragraph.</p>

The second-to-last example is of a paragraph tag being implicitly closed by the appearance of another block-level element (in this case, a table) since paragraphs can’t contain other block-level elements. As a result, the paragraph element is empty and its intended end tag (after the table) is orphaned, causing an error.

Note also that the HTML 4.01 Specification discourages the use of empty paragraph elements.


  • Remove the tag or type some text in it.
  • If the element is being reserved for dynamically generated script content, insert the element via scripting instead.