Topics

×

Search Question

What is the head section in HTML?

By: Ravindra Kumar | 04 May 2019

A

Ankush Singh

05 August 2020

Head section in HTML

An HTML page divided into two main parts (HTML page is also called as HTML document)

  1. Head Section
  2. Boby Section

Both the Head section and Body section are rendered between main <html> and </html> tags. Below is the structure of an HTML document (HTML Page)


<html>

      <head></head>

      <body></body>

</html>


Between <body> and </body> tags we put all other tags, images, text, etc. which we want to show in our web page, In simple words whatever we put between <body> and </body> that is going to appear in our web page but in case of <head> tag is totally different, so let's know why we use the head tag in the HTML page


The Head section is used to control the complete HTML page ( mainly body section) for that how the page will behave and appear. Let's take a real-world example, take the example of your body, suppose your whole body like an HTML page in which there is a mind which is invisible, and second is your rest of the body. Your mind gives instructions to your body and your body does the task accordingly, for example, moving your hand, speaking, walking, etc. People can see your body that how it looks like but they can't see your mind. The HTML page works same, <head> </head> tag is used to control the complete HTML page. Below I'm going to list points about that we do in the head section.

All code which we want to write in the head section we write between <head> and </head> tags.


1. Page Title

In head section we use <title> </title> tag to provide a tile to our webpage. In the web browser title text appears above the URL.

The <title> tag is optional but it is good practice to use <title> tag it helps search engine to rank your web page in the search result.


<head>

          <title>Home Page</title>

</head>


2. Meta Tags

Meta tags are basically used for SEO purpose in with we tell to search engine that do we want to rank our page or not, if we want to rank page then on which keywords and description, don't worry it these this are new for you, these are the parts of SEO, you will learn it after learning HTML


<head>

         <meta name="keywords" content="home page, home," />

</head>


3. CSS/ JavaScript Codes

In the head section, we can write required CSS and Javascript code, it is good practice to write CSS and Javascript code in head section rathe than inline CSS because it is reusable and easy to maintain.


<head>

         <style>

              body{

                         padding:0;

                         margin:0;

                         background-color:brown;

                      }

                   p {

                          font-size:15px;

                       }

         </style>

</head>


4. External CSS/ Javascript / JQuery Files Link

The Head section allows us to like our external CSS, Javascript, JQuery files in our HTML page, we put all such links between <head> and </head>


<head>

         <link href="../style/site_style.css" rel="stylesheet" />

</head>

11 votes

N

Nirmal KJ

11 May 2019

We can use some important tag between the head opening <head> and closing tag </head>


  1. A title tag <title> for the web page title, 
  2. Link tag <link> use for external CSS code, 
  3. Javascript tag <script> use for external javascript code, 
  4. Meta tag <meta> in the head section of HTML.

1 votes

P

Pankaj Kumar Tripathi

25 June 2019

The HTML head section uses to provide some important information about the web page for example - Page title, external CSS link, external script link, internal CSS & Script code, etc. The basic structure of the HTML Head section mentioned below:

<html>

       <head>

              <title>Web page Title Name</title>

              <link />Here we can link a external css file

              <script />Here we can link external script file

              <style>Internal CSS code, we can write here</style>

              <script>Internal Script code, we can write here</script>

       </head>

</html>

1 votes

Your Answer

Policy

GDATAMART.COM is optimized for learning & job information; The users try to improve your knowledge and practical experience through this site but we cannot warrant full correctness of all content... Learn More →

© 2020 GDATAMART | All Rights Reserved