HTML Close Tags

Here are some hints on how/when to use HTML close tags.
  • HTML tags are nested. This means you have to close the last tag you opened (see Example #1)
  • If your DOCTYPE is XHTML, you will have to close all tags, including input's and br's. <h1></h1> is the same in both HTML and XHTML, but with XHTML you would have to write <br /> and <input />. HTML5 allegedly allows self-closing tags (i.e. <br> instead of <br />) but the standard is not yet ratified by W3C and constantly changing.
  • Even though some browsers are alright if you occasionally forget to close a tag, don't rely on it. Not closing, for example, an H1 tag could render your whole page in a huge, bolded font. 

HTML Example:

Example #1
Proper order of closing tags: text
 

Share

Learn how to design amazing websites