Skip to content
Related Articles

Related Articles

Improve Article

Essential HTML Tags

  • Last Updated : 20 Aug, 2021

HTML stands for HyperText Markup Language. It is an important language to design web pages or websites. These websites are visible to anyone on the internet. HTML is a combination of Hypertext and Markup language. Where hypertext is a link between the webpages, and markup language is used to define the text document within a tag, that defines the structure of the web pages. 

HTML uses predefined tags that tell the browser how to display the content. Tags are nothing but some instructions that are enclosed in angle braces(i.e., <>). It is divided into three parts, i.e., opening tag, content(which will display on the browser), and closing tag, but some tags are special tags that do not contain closing tags like <BR> tag. When you are working with HTML tags always remember to include closing tags. If you forget to close the tag, the browser applies the effect of the opening tag until the end of the page. HTML contains four essential tags that form the basic structure of any webpage or HTML file:

  1. <html></html>
  2. <head></head>
  3. <title></title>
  4. <body></body>

Now let us discuss each tag one by one:

1. <!DOCTYPE html>

It is also known as document type and should be included in an HTML file. It actually tells the browser that this is an HTML document. It is not a tag or an element but it is information. 



Syntax:

<!DOCTYPE html>

2. <html></html>

This tag marks the beginning and ending of the HTML document and whatever code is present in between these tags totally gets considered by the browser. Also, it tells the browser that the document is an HTML document. All the other tags in between these tags only get considered by the browser.

Syntax:

 <html> Content </html>

3. <head></head>

This tag store the data which actually doesn’t appear on the webpage but it gives more information about the webpage. Or in other words, this tag is used to define the head part of the document which contains the information related to the webpage. It also contain tags like, <title>, <meta>, <link>, <style>, etc.



Syntax:

<head> <title> Title of the Webpage </title></head>

4. <title> </title>

This tag stores the title/name of the web page. Whatever title/content is given in this tag, the content appears on the tab when opened by the browser. It is described in the head tag.

Syntax:

<title> Title of the Webpage </title>

5. <body></body>

This tag is used to display all the information or data, i.e, text, images, hyperlinks videos, etc., on the webpage to the user. Here, all the content like text, images, hyperlinks videos, etc., are enclosed between this tag.

Syntax:

<body> Content </body>



Some other HTML tags are:

1. <!– comment –>

This tag is used to add comments in the HTML codes. These comments help the program to understand the code. The content inside the comment tag doesn’t visible on the browser. 

Syntax:

<!–Write comments here –>

2. <meta> 

These meta tags are used inside the head tag and they making describe the metadata i.e data about data. These tags are useful in search engine optimization which means when users search for our websites the chances that the browser recommends our webpage becomes high which leads to an increase in traffic over the webpage. A single HTML document can contain multiple tags.

Syntax:

<meta attribute-name=”value”>

3. <link rel =”stylesheet” href=”file.css “>

This tag is used to include external style sheets. Use this tag when you don’t want to include CSS in the HTML document. To make it more simple we make a CSS file with the code and include this file in the link tag.

Syntax:

<link rel =”stylesheet” href=”file.css “>

4. <script></script>

It is used for including javascript code. The external javascript can also be linked using the src attribute in the opening script tag. It can be included in the head or body tag.

Syntax:

<script>script content</script>

5. Heading:

HTML provides six types of headings, i.e., H1, H2, H3, H4, H5, and H6. Here, H1 is the highest level heading and H6 is the lower level heading. These headings are used to highlight the important topics.

Syntax:



<h1> content </h1>

<h2> content </h2>

<h3> content </h3>

<h4> content </h4>

<h5> content </h5>

<h6> content </h6>

 Example 1: 

Simple HTML program:

HTML




<!DOCTYPE html>
<html lang="en">
<head>
     
    <!--The description written on title tag get appeared as browser tab name-->
    <title>Geeks For Geeks </title>
 
</head>
 
<!-- Whatever content in body tag appears on the webpage-->
<body>
     
    <h1> Geeks For Geeks </h1>
    <h3> A computer science portal for geeks </h3>
     
</body>
</html>

Output:



 Example 2: 

HTML program in which we are adding external CSS using the <link> tag

HTML




<!DOCTYPE html>
<html lang="en">
<head>
   
    <!--Meta data-->
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!--Including css file with name GFG.css-->
    <link rel="stylesheet" href="GFG.css">
    <!--The description written on title tag get appeared as browser tab name-->
    <title>Geeks For Geeks </title>
 
</head>
   
<!-- Whatever content in body tag appears on the webpage-->
<body>
   
    <h1> Geeks For Geeks </h1>
    <h3> A computer science portal for geeks </h3>
   
</body>
</html>
GFG.css
body {

   text-align: center;
}
h1{
    color: darkgreen;
}
h3{
    color:darkgreen;
}:

Output: 

Example 3: 

HTML program in which we are adding javascript file GFG.JS using <script> tag: 

HTML




<!DOCTYPE html>
<html lang="en">
<head>
   
    <!--Meta data-->
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!--Including css file with name GFG.css-->
    <link rel="stylesheet" href="GFG.css">
    <!--The description written on title tag get appeared as browser tab name-->
    <title>Geeks For Geeks </title>
 
</head>
   
<!-- Whatever content in body tag appears on the webpage-->
<body>
   
    <!--Including JS file with name GFG.JS-->
    <script src ="GFG.JS"> </script>
    <h1> Geeks For Geeks </h1>
    <h3> A computer science portal for geeks </h3>
    <button onclick="darkMode()"> CLICK ME TO GET DARK MODE</button>
   
</body>
</html>

Javascript




function darkMode() {
    document.body.style.backgroundColor = "black";
}

Output:

On clicking the button.

Attention reader! Don’t stop learning now. Join the First-Step-to-DSA Course for Class 9 to 12 students , specifically designed to introduce data structures and algorithms to the class 9 to 12 students




My Personal Notes arrow_drop_up
Recommended Articles
Page :