Principles For Clean HTML Code(Markup)

Beautiful HTML is the foundation of a beautiful website. The advantages of clean, semantic HTML are many. There are so many websites suffer from poorly written markup. There are some principles to consider during and after you write your HTML, CSS to help keep it tight and optimized. Clean and optimized code is important not just for file size, but for maintenance and readability as well.

Here I bring few points to begin the discussion.

  1. Strict DOCTYPE
  2. Character set & encoding characters
  3. Proper indentation – HTML TIDY (tool)
  4. Keep your CSS and JavaScript external
  5. Nest your tags properly
  6. Eliminate unnecessary divs
  7. Use better naming conventions
  8. Leave typography to the CSS
  9. Class/id the
  10. Validate
  11. Logical ordering


Clean And Optimized CSS

  1. Use Shorthand
  2. Use whitespace wisely that is important for readability
  3. Prune frameworks and resets: this help to neutralize a browser’s default style
  4. Future-proof your CSS by separating layout styles from the rest of the styles
  5. Document your work. This includes documentation on markup guides and style sheet guides and CSS comments
  6. Make use of compression. This is all about CSS magnification



To view or add a comment, sign in

More articles by Dibu John

Explore content categories