Even if you don't close the closing tag, they may be still be looking fine in the browser but it is not a good practice to leave the closing tag open.
Frequently Asked Questions
is hr a self closing tag?
Yes, hr is a self closing tag and you need not close it like .
is img a self closing tag?
Yes, img is a self closing tag and it only has attributes and no content inside. You need not close it like.
is input a self closing tag?
Yes, input is a self closing tag. You need not close it as it is an empty tag. It only has attributes but no content.
which of the following is not a self closing tag?
1. 2.
3. 4.is not a self closing tag, em tag is used for emphasis content.
which of the following is a self closing tag?
1.
2. 3. 4. is a self closing tag, it is used to connect other document to your HTML file, mostly used to add external stylesheet.
Self closing tags do not require a closing tag. | Closing tags require a closing tag. Example - |
Self closing tags do not have contents inside. They are either blank or get data to render from attributes. | Closing tags have contents inside. Example - This is a paragraph |
Self closing tags do not have child elements. | Closing tags have child elements. |
Conclusion
self closing tags are empty tags that do not have content. They do not need to be closed however if self closed by /> then ignored by browsers.
- In HTML5: Closing empty tags by a slash is optional
- In XHTML: Closing empty tags by slash necessary