TOP CATEGORIES

×

What is the head section in HTML?

A

Ankush Singh

Head Section in HTML

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

  1. Head Section
  2. Boby Section

Both sections are rendered between main <html> and </html> tags, for more understanding see the below example:

<html>

      <head></head>

      <body></body>

</html>

Between <body> and </body> tags we put all other tags, images, text, etc. which we want to show on our web page, In simple words whatever we put between <body> and </body> is going to appear in our web page but in case of <head> tag is 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 the body section) for how the page will behave and appear. Let's take a real-world example take the example of your body, suppose your whole body is like an HTML page in which there is an invisible mind, and second is the 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 and how it looks like but they can't see your mind. The HTML page works the same <head> </head> tag is used to control the complete HTML page.

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

1. Page Title

In the 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 engines rank your web page in the search results.

<head>

          <title>Home Page</title>

</head>

2. Meta Tags

Meta tags are used for SEO purposes in which we tell search engines whether we want to rank our page or not, if we want to rank the page then on which keywords and description, don't worry these this is 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 the required CSS and Javascript code, it is good practice to write CSS and Javascript code in the head section rather 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, and JQuery files on 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

Use some important HTML tags between the head opening <head> and closing tag </head>

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

1 votes

P

Pankaj Kumar Tripathi

HTML Head Section

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 is mentioned below:

<html>

       <head>

              <title>Web page Title Name</title>

              <link />Here we can link an external CSS file

              <script />Here we can link the 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

Email: advertise@gdatamart.com

Donate: To Support US

© 2024 GDATAMART.COM (All Rights Reserved)