What’s the Point of the HTML Head Tag?

I get that question often. One of our students Ahmed  recently asked me "What is the importance of the  head tag? I see that the title tag is enough. What will happen if we remove the head tag?" This is a really wonderful question. It should be

I get that question often. One of our students Ahmed  recently asked me “What is the importance of the  head tag? I see that the title tag is enough. What will happen if we remove the head tag?”

This is a really wonderful question. It should be exactly the way you think when you are learning new things. If it is not logical; then ask why. It is true that when all you have in your head tag is just one thing, that it may seem silly to have a wrapping tag that does nothing. The goals of the wrapping tag are very deep. The wrapping tag categorizes the content within them. Imagine this example:

if you are hungry

eat something

take a nap

For non-programmers what this is saying is that; if you are hungry, eat something, and then take a nap. But for a computer it my not mean that. It can/could mean many other things also, such as:

1) if you are hungry. eat something. take a nap. – 3 separate sentences when the first one is an incomplete sentence.

2) if you are hungry. eat something. take a nap. even if your not hungry you can take a nap [Boolean Logic and, or option].

3) if you are hungry. eat something.  take a nap[if, then, else option] .

For a computer program to work we need to try to be as explicit as possible. This is true for anything in programming. Even as you delve into the world of JavaScript or other programming languages. For now your HTML is structure bound. If you remove elements of the structure you have something that can be misunderstood by someone – may it be the search engine, the browser, or sometimes the users. This structure sometimes seems useless, but it is critical that it be “legal” html. When large search engines think about indexing your pages (or not) they first test to see if your page is “pro”. It’s a great way to weed out content. If your content doesn’t match a basic code of conduct, you tend to get less effective outcomes from your web pages.

The three fore mentioned examples, if they were to be written in JavaScript, would be written something like this:

if(are you hungry){

eat something;

go to sleep;

}

By bounding the question in  { } we enable the computer to understand that if you are hungry then do everything in this list. Always think about it this way. Even with the most basics, like the start of html training. It’s all connected and really simple. Never add extra things just for fun of it. This way we all use the same structure.

<html>

<head>

</head>

<body>

</body>

</html>

The actual HTML tag does nothing but is critical, it is the root element of the page. In the HTML tag we always want to have a head tag and a body tag. Both on their own do nothing. The head contains all the information related to the background information and the body contains all the content. When you have a lot of content it starts becoming logical if your head area has 10 tags. That way it is clear. We know where it starts and where it ends. In a case of a lone title you might think “well its logical that its part of the head – so what’s the big deal”. In programming we always want to bound things. There is no room for personal interpretation of “what did the other programmer mean”.  Programming as much as it is similar to the spoken language, it is different. Mainly in the factor that in programming you have to be very specific and can’t have something written that can be interrupted in more than one way.

P.S – as you continue with our HTML course on 02geek.com you will learn about self-contained tags such as the BR tag. Historically before HTML4-5 it was written this way:

<br></br>

Later on to unify the structure and make it a valid rule (from the rules of XML) they changed it to :

<br />

It is clear that this tag doesn’t open and close but is self-contained; its not open to interpretations.

This is really important in programming and something you want to think about a lot as you continue to learn how to program in any language. From HTML all the way through to advanced programming languages. You will always want to define a very clear scope(where does something start; where does it end; who are we talking about). You need to know where something starts and where it ends. No one should misunderstand, and/or misinterpret where it starts and ends.

In our case the title tag in the head tag makes it very clear that the title relates to the head of the HTML page. If the title was in the body it would be related to the body. If it is floating around then it’s open to interpretation – that’s something you want to always avoid in programming.

I hope this helped you. Furthermore, I hope you all think about this as you start exploring and learning how to code.

So why isn't there a Neck Tag?
So why isn’t there a Neck Tag?
– go from a “zero to geek” | 02Geek.com – ©

Leave a Reply

Be the First to Comment!

Notify of
avatar

wpDiscuz