Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • HTML Tutorial
  • HTML Exercises
  • HTML Tags
  • HTML Attributes
  • Global Attributes
  • Event Attributes
  • HTML Interview Questions
  • HTML DOM
  • DOM Audio/Video
  • HTML 5
  • HTML Examples
  • Color Picker
  • A to Z Guide
  • HTML Formatter
Open In App
Next Article:
Is container tag same as the empty tag in HTML? If not, why ?
Next article icon

Is container tag same as the empty tag in HTML? If not, why ?

Last Updated : 02 Feb, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

In this article, we will see the container tag & empty tag in HTML, along with knowing how they're different from each other. The Container tag is not the same as the empty tag & these are two different categories of tags used in HTML.

Container tag: This tag contains 3 parts, namely, the opening tag, content that will be displayed in the browser & the closing tag. If we forget to add the closing tag then the browser will continue to implement the effect of that opening tag on the content inside of that tag. This will deform the structure of the overall webpage.

Syntax:

<Tag_Name> Content </Tag_Name>

List of commonly used Container Tags:

  • Root Tags of HTML Document: These are some root elements of every HTML document, without including these tags in HTML we can not create web pages.
    • <html></html>: It is the root element of an HTML document that indicates the start & end of the webpage, along with rendering the content which is inside of it.
    • <head></head>: This tag contains some abstract information related to the webpage, which is not directly displayed but utilized to enhance the overall webpage. 
    • <title></title>: This tag contains the title of the HTML document that is shown in the browser tab. It is described inside the head tag.
    • <body></body>: The body tag contains all the data that will be visible on the webpage.
  • Heading Tags: Heading tags are used to provide headings of different text sizes and styles to your web page. Heading tags vary from <h1> to <h6>.
  • Lists: There are 3 different list tags used for listing different items in a particular way, which is given below:
    • <ol></ol>: This list tag is used to list the items in a particular order ie., numerical, alphabetical, or roman numerals. The <li> tag is used to add list items inside of it.
    • <ul></ul>: This list tag is used to list the items in bulleted form. The shape of the bullet can be changed to disc, circle & square. It also uses the <li> tag to add list items.
    • <dl></dl>: This is an definition list tag. It uses <dt> the data term tag and <dd> the data description tag to add items inside it.
  • Text Formatters: These tags define the way in which text will be shown on the web page.
    • <p></p>: This is the paragraph tag used to add text on the webpage.
    • <b></b>: The bold tag is used to display the boldened text that is important on the web page.
    • <i></i>: The italic tag display the text in the tilted form.

These are also some container tags that are generally used inside an HTML document.

  • <div></div>: This tag is used to create a separate container on the web page that also can use other tags inside it.
  • <a href=""></a>: This tag is used to provide links for different pages on the web page.
  • <button></button>: This is a button tag that is used to form an button on the web page to perform some actions.
  • <nav></nav>: The nav tag is used to build the navigation bar on the website.
  • <script src=""></script>: The script tag is mainly used to link an external JavaScript file using src attribute or you can write JavaScript code inside this tag directly in HTML document.
  • <iframe src=""></iframe>: Iframe tag is used to display nested web pages. It represents a web page inside another web page.

Example: The example below demonstrates the use of container tags in HTML.

HTML
<!DOCTYPE html> <html lang="en">  <head>     <meta name="viewport" content=         "width=device-width, initial-scale=1.0">      <title>         Container tag & Empty tag in HTML     </title> </head>  <body>     <h2>Welcome To GFG</h2>     <h3>         Here are some common container          tags used in this code:     </h3>      <p>Hey! This is a paragraph.</p>      <h3>Below is an description list:</h3>     <dl>         <dt>GeeksforGeeks</dt>         <dd>             GeeksforGeeks is an online learning             platform for geeks around the globe.         </dd>         <dt>Notebook</dt>         <dd>             Notebook is a collection of pages             (plane or linear) that is used to             make notes of some important things.         </dd>     </dl>     <button>Click Me!</button> </body>  </html> 

Output:

Empty Tags: Empty tags are the tags that only contain the opening tags, they do not have any closing tag. Hence they don't affect the webpage if we forget to close any empty tag.

Syntax:

<Tag_Name>

Here are some empty tags that are generally used in HTML documents:

  • <input>: This tag is used to take input from users. It is mainly used inside a form tag.
  • <img>: It is an image tag that is used to insert an image on the web page.
  • <br>: The break tag is used to break the line and skip to the next line.
  • <link>: The link tag is used to link the external CSS file to the current HTML document.
  • <hr>: It is used to insert a horizontal line on the web page whenever needed.
  • <source>: The source tag is used to insert an external media file to the web page that can be an Audio or Video file.
  • <meta>: It stores the meta-information about the web page that is information about data that we don't want to show to users on the web page.

Example: The below example illustrates the use of the empty tags in HTML.

HTML
<!DOCTYPE html> <html lang="en">  <head>     <meta name="viewport" content=         "width=device-width, initial-scale=1.0">     <title>         Container tag & Empty tag in HTML     </title> </head>  <body>     <h2>Welcome To GFG</h2>     <h3>         Here are some common empty          tags used in this code:     </h3>      <p>Hey! This is a paragraph.</p>      <br>     <hr>     <img src= "https://media.geeksforgeeks.org/wp-content/uploads/20220125210128/gfglogo.png"         alt="GFG_logo"         height="300px" width="300px"> </body>  </html> 

Output:

S. No.

Container Tags

Empty Tags

1.

It contains the opening tag, content, & the closing tag.

It has only the opening tag, & do not have any end tag.

2.

Container tags may contain the empty tag inside in it.
Eg.: <p><br></p>.

Empty tags do not contains any tag, it use only attributes inside in it.
Eg: <img src="" alt="">.

3.

Container tags can be used to define the behavior of text inside in it.

Empty tag do not have any text content inside in it.

4.

The nesting of the tags can be possible in this case.

The nesting of tags is not possible.


Next Article
Is container tag same as the empty tag in HTML? If not, why ?

A

abhisheksainiaggarwal
Improve
Article Tags :
  • HTML
  • HTML-Tags
  • HTML-Questions

Similar Reads

    Container and Empty Tags in HTML
    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., <>). Tags are used in many places of the webpage but many users are often confused about some tags whether it is a container or an empty ta
    6 min read
    Is HTML elements are same as tags or not ?
    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 w
    2 min read
    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 <p> for paragraphs or <img> for images, and can include attributes for additional information. So to better understand which tags are opening and clo
    5 min read
    What is the meaning of DOCTYPE in HTML ?
    The HTML document type declaration or Doctype is an instruction used by web browsers to fetch what version of HTML the website is written in. It helps browsers in understanding how the document should be interpreted thus eases the rendering process. It is neither an element nor a tag. The doctype sh
    2 min read
    What is the difference between <section> and <div> tags in HTML?
    In web development, both the <div> and <section> tags are commonly used to structure content. The <section> tag is semantic and indicates that the enclosed content relates to a specific theme or topic, making it more meaningful for search engines and accessibility tools. In contras
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences