RayL Posted February 12, 2022 Share Posted February 12, 2022 We're told that <br> is an empty element and it has no end tag. Is "<p></p>" an empty element? It has no content ("stuff between the start/end tags"). Is it true that "empty elements" have no end tag? If it is, then why does "<p></p>" have an end tag, given it has no content and is therefore an empty tag? Link to comment Share on other sites More sharing options...
Ingolme Posted February 13, 2022 Share Posted February 13, 2022 An empty element is one which has no purpose for the content between the tags. Empty elements do not need an end tag and shouldn't have one. While <p></p> is empty, it's not considered an "empty element" because when there is something between the tags, it's meaningful. This is not common practice, but specific elements such as <p> and <li> actually can work without a closing tag. This is because the browser know that the content of a <p> element must end as soon as it runs into another block element or when its parent ends. Link to comment Share on other sites More sharing options...
dsonesuk Posted February 20, 2022 Share Posted February 20, 2022 Just because a bucket is empty does not mean it is no longer a bucket..its just a empty bucket. Same goes for empty p, div etc. A tag of br, hr, input, img etc is referred to as a void element. It can never hold, contain content. Link to comment Share on other sites More sharing options...
bhawna06 Posted July 1, 2022 Share Posted July 1, 2022 Element without an enclosing tag is known as an empty element. The closing tags cannot be added to empty elements. No child nodes exist for empty elements. As a result, empty tags are self-closing or void in nature, and are not container tags. For input, meta-data, area, etc., empty elements can be used to embed images, lists, breaks, horizontal lines, hyperlinks, etc. For instance, <p> tag had a closing tag hence it was not an empty element. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now