HTML: formatting instead of WYSIWYG
You're looking for HTML Tidy module.


  This module tidies Drupal's HTML output with HTML Tidy by optionally
  sanitizing it when it is saved or when it is displayed, like a
  traditional input formatter. Missing and mis-ordered tag components
  are replaced and reordered automatically so that user input doesn't
  break site structure with open tags and the like.
  
  User interface configuration supports:
  
  Code indenting: Automatically format HTML for easier reading, or strip
  indenting for proper parsing and display in the less compliant
  browsers. Word wrapping: Automatically wrap lines in an intelligent
  fashion once they get to a specified length Info/Warning/Error
  information: Optionally appended to pages and includes details about
  the wrong HTML attributes and W3C validation info.