What are Empty Tags in HTML?

Learn via video course
FREE
View all courses
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
Topics Covered

The HTML consists of several elements and their associated tags to represent some corresponding view on the screen. As you might know from the concept of the Document Object Model in HTML, the entire HTML Document can be represented in a tree structure where each node corresponds to an element, and they can have their attributes as well as child nodes. But not every HTML element can have a child node, and those all are called Empty Elements.

Although if we try to embed content in the empty element, HTML will not stop rendering it, the HTML parses it in a way that nested content gets positioned at the same level just after that empty element in DOM, but it is not a good practice because some framework, library, etc. might throw an error in this situation.

List of Empty Elements used in HTML

ElementDescription
imgIt accepts a source link of the image and some other attributes like height, width, etc., and is used to embed the image in the HTML Document.
brThe term br is an abbreviation for a break. It introduces a line break in the document.
hrThe horizontal rule is used to introduce a graphical line in the HTML document. It is also called a thematic break. Follow this.
areaThe area element is used inside the image map. It defines some particular clickable areas for the image, which further may lead the user to a different link.
embedThe embed element is used as a container to display any external resource like image, video, plugin, etc.
inputThis element is used to receive input from the user.
metaWe write this element in the head tag of the document. It is used to specify some metadata (information) about the page.
sourceThe source element specifies the media element for the picture, video, or audio element.
colIt is used inside the colgroup element of tables in HTML and specifies the common properties of columns, ex-style.
linkIt establishes a link or association between some external resource and an HTML document. It is generally used inside the head tag.

Examples

1. img element

Output: Img Element Output

2. br and hr element

Output: br Element output

3. input element

Output: hr element output

4. embed element

Output:

GIF  START SAMPLE

Conclusion

  • In this article, we have discussed the empty elements of HTML.
  • Some examples of empty tags are img, embed, area, meta, link, etc.
  • The empty elements are those elements of HTML that cannot have some content like text or child element inside them.
  • There is no need to specify the closing tag, and the opening tag should end with /> instead of >. The proper syntax to write these elements is <tagname attributes="values"..... />.