HTML coding guidelines

This is my third article about coding guidelines. In this article I wanted to give you some general guidelines for HTML coding that will help to improve readability, maintainability and code reuse. It will reduce browser related problem. Following are some guidelines:

  • Must be use doctype in your web page.
  • Everyone should be write well-formed HTML code.
  • Indent HTML code constantly
  • Use small letter constantly. It will increase readability.
  • ID should be unique in a page and pick a meaningful name for this. Should be follow a standard constantly. Can use underscore (_) to separate meaningful words.
  • Name tag can follow a same standard like ID. It will be easier to read.
  • Should be use ID for dynamic element.
  • Avoid inline CSS. Use separate file for CSS stylesheet.
  • Avoid longer line. Break the line when a statement will not fit on a single line.
  • Use commenting as less as possible but use sensibly.
  • All nested attributes must be properly nested.
  • Attributes must be quoted.
  • Validate HTML code using W3C validation service at – http://validator.w3.org

Some related posts:

Leave a Comment