Open In App

Tags vs Elements vs Attributes in HTML

Last Updated : 14 May, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

In HTML, tags represent the structural components of a document, such as <h1> 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.

Group-3-2-(1)

HTML Tags:

HTML Tags are the starting and ending parts of an HTML element. They begin with < symbol and end with > symbol. Whatever is written inside < and > are called tags.

Example:  In this example <b> is the starting tag and </b> is the ending tag.

html
<b> </b>

HTML elements:

The HTML element consists of both the opening and closing tags as well as what’s inside those tags. It normally consists of some structure that’s used to define the respective tags.

Example: In this example <b> is the starting tag and </b> is the ending tag but with content inside it.

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

HTML Attributes:

HTML Attributes is used to define the character of an HTML element. It always placed in the opening tag of an element. It generally provides additional styling (attribute) to the element.

Example:  In this example <p> is the starting tag and </p> is the ending tag with extra css attributes.

html
<p align="center">This is paragraph.</p>
This is paragraph.

Tags vs Elements vs Attributes difference

HTML TagsHTML ElementsHTML Attributes
HTML tags are used to hold the HTML element.HTML element holds the content.HTML attributes are used to describe the characteristic of an HTML element in detail.
HTML tag starts with < and ends with >Whatever written within a HTML tag are HTML elements.HTML attributes are found only in the starting tag.
HTML tags are almost like keywords where every single tag has unique meaning.HTML elements specifies the general content.HTML attributes specify various additional properties to the existing HTML element.

Tags define the type of HTML element (e.g., heading, paragraph).

Elements represent the complete, functional unit on a webpage.

Attributes provide extra information or settings for elements.


Next Article

Similar Reads