Open In App

Is HTML elements are same as tags or not ?

Last Updated : 02 Feb, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

HTML elements and tags are a lot different. Let’s see what HTML elements and Tags actually are and their differences. The below image tells about HTML Elements and HTML Tags.

HTML Tags: The starting and ending point parts of an HTML document are HTML Tags, which start with < (less than) and end with >(greater than) angle bracket, and whatever is written inside the angle brackets are known as tags.

Both opening and closing tags must be there in order to function. There are also some self enclosing tags which require only one tag such as <hr>, <img>, <br> etc. The ending slash over here is optional.

Syntax:

<tagname>
    ...
</tagname>

Example: This example shows how a paragraph tag is used (consist of both start and end) and <hr> tag (self-closing tag).

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>HTML Tags</title>
    <style>
        .container {
            height: 180px;
            width: 300px;
            background-color: green;
            color: whitesmoke;
            text-align: center;
            font-family: 'Courier New', Courier, monospace;
            margin: auto;
        }
  
        p {
            font-size: 18px;
        }
    </style>
</head>
  
<body>
    <div class="container">
        <h2>HTML Tags</h2>
        <p> Paragraph Tags - <p> </p></p>
        <hr>
        <p>The above line is due to <hr> tag</p>
    </div>
</body>
  
</html>


Output:

HTML Elements: Elements in HTML enclose the content in between the tags. It consists of an expression or a structure. Its architecture consists of a start tag, content followed by an ending tag.

Syntax:

<b> This is the content. </b>

Example: This example shows the use of HTML Elements in the code.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>HTML Elements</title>
    <style>
        .container {
            height: 200px;
            width: 350px;
            background-color: green;
            color: whitesmoke;
            text-align: center;
            font-family: 'Courier New', Courier, monospace;
            margin: auto;
        }
  
        p {
            font-size: 18px;
        }
    </style>
</head>
  
<body>
    <div class="container">
        <h2>Gfg - HTML ELements</h2>
        <p>Everything within tags is HTML Element</p>
  
        <p>Visit
            <a href="https://www.geeksforgeeks.org/" 
               target="_none">GeeksforGeeks</a>
            wesbite.
        </p>
    </div>
</body>
  
</html>


Output:

Let’s see the difference between HTML elements and tags in deeper:

HTML Tags

HTML Elements

HTML Element is held using HTML Tags Content is held using HTML elements.
Starts with < and ends with > Everything within a HTML Tag is HTML element.
They are keywords where every specific single tag has some unique meaning. They specify the general content.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads