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.


Similar Reads

Which tags contain both opening & closing tags in HTML ?
HTML tags are markers that define the structure and content of web documents. They consist of angle brackets enclosing a tag name, such as &lt;p&gt; for paragraphs or &lt;img&gt; for images, and can include attributes for additional information. So to better understand which tags are opening and closing in nature, we can divide them into 4 parts. D
5 min read
RegEx to Match Open HTML Tags Except Self-contained XHTML Tags
We will learn to Create a regular expression pattern that matches open tags in HTML except for self-contained XHTML tags. A regular expression (RegEx) can be used to match open tags, excluding XHTML self-contained tags(For Eg- &lt;br/&gt;, &lt;img /&gt;). This can be achieved by creating a pattern that matches opening angle brackets followed by a t
2 min read
How to display HTML tags as plain text in HTML ?
In this article, we will learn how to display HTML tags as plain text in HTML. We can replace the plain text by using &lt; with   &amp;lt; or &amp;60; and &gt;   with  &amp;gt; or &amp;62; on each HTML tag. HTML Entities:Sign DescriptionEntity nameEntity number&lt;Less than(start of HTML element)&amp;lt;&lt;&gt;Greater than(end of HTML element)
2 min read
Tags vs Elements vs Attributes in HTML
In HTML, tags represent the structural components of a document, such as &lt;h1&gt; for headings. Elements are formed by tags and encompass both the opening and closing tags along with the content. Attributes provide additional information or properties to elements, enhancing their functionality or appearance. Table of Content HTML Tags: HTML eleme
2 min read
Essential HTML Tags
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 s
5 min read
HTML Deprecated Tags
The deprecated tags or attributes are those attributes which are replaced by some other attributes. The tag or attributes deprecated when the same attributes is achieved by some other way. They are considered outdated and may not be supported in modern browsers or future versions of HTML. HTML Deprecated Tag: Complete list of deprecated tags are gi
2 min read
How to display HTML tags as plain text using PHP
HTML tags begin with the less-than character and end with greater-than character, the text inside the tag formatted and presented according to the tag used. Every tag has special meaning to the browser but there are cases when to show plain HTML code in webpage. There are various methods in PHP to show the HTML tags as plain text, some of them are
3 min read
How to remove HTML tags with RegExp in JavaScript ?
Here, the task is to remove the HTML tags from the string. Here string contains a part of the document and we need to extract only the text part from it. Here we are going to do that with the help of JavaScript. Approach: Take the string in a variable.Anything between the less than symbol and the greater than symbol is removed from the string by th
2 min read
Use of blockquote, q and cite tags in HTML
HTML | blockquote Tag: The &lt;blockquote&gt; tag in HTML is used to display the long quotations (a section that is quoted from another source). It changes the alignment to make it unique from others. It contains both opening and closing tags. Syntax: &lt;blockquote&gt; &lt;p&gt;The quote is input here.&lt;/p&gt; &lt;/blockquote&gt; Example: In thi
2 min read
Program to remove HTML tags from a given String
Given a string str that contains some HTML tags, the task is to remove all the tags present in the given string str. Examples: Input: str = "&lt;div&gt;&lt;b&gt;Geeks for Geeks&lt;/b&gt;&lt;/div&gt;" Output: Geeks for GeeksInput: str = "&lt;a href="https://www.geeksforgeeks.org/"&gt;GFG&lt;/a&gt;" Output: GFG Approach: The idea is to use Regular Ex
3 min read