{"id":4698,"date":"2017-06-09T05:30:54","date_gmt":"2017-06-09T09:30:54","guid":{"rendered":"http:\/\/local.brightwhiz\/?p=4698"},"modified":"2021-12-08T12:01:23","modified_gmt":"2021-12-08T17:01:23","slug":"html-tags-optional","status":"publish","type":"post","link":"http:\/\/local.brightwhiz\/html-tags-optional\/","title":{"rendered":"Why Should I Write HEAD, BODY and HTML Tags?"},"content":{"rendered":"\n

It is no secret in web design that elements such as the HEAD, BODY, and HTML<\/a> tags are optional according to the HTML5 specifications. If you did not know that then now you know.<\/p>\n\n\n\n

So the bigger question arises as to why web developers and designs spend so much time meticulously crafting their code to stay pretty and have these tags in place?<\/p>\n\n\n\n

Here’s the Thing About the HEAD, BODY and HTML Tags<\/h2>\n\n\n\n

It is not so obvious to web designers that these tags are optional. After all, every single Integrated Development Environment<\/a> (IDE) and simple HTML editor sticks these tags in as boilerplate code. Therefore it has been ingrained in us that these tags are a requirement.<\/p>\n\n\n\n

Technically if you omit these tabs every modern web browser<\/a> will insert the tags. You can take this statement with a pinch of salt as IE 9 has a bug where it incorrectly inserts the tag, especially where there is a form tag in the mix.<\/p>\n\n\n\n

  1. That right there is the first reason why you should explicitly add the HEAD, BODY and HTML tags to your HTML documents. You want to avoid triggering browser bugs which can make for some very interesting artifacts on your website.<\/li>
  2. For readability purposes, it is good practice to just add the tags to allow others in the development team easier understand the code and what you are trying to do. For example you may want a script to explicitly sit in the BODY section of your website. Maybe the script is meant to display something exactly where it is placed.
    If that placement is at the top the page there is a likelihood that the browser might bump it to the HAD section when it creates these tags.<\/li>
  3. Adding these tags allows you to assign classes and IDs to them which can be quite useful in crafting that perfect UI.<\/li><\/ol>\n\n\n\n

    Here is some detail about what the specification says about these tags:<\/p>\n\n\n\n