0

Why are some tags self-closing whereas others are not?

<img> <br> are self -closing but <video> isn't !

10th May 2020, 3:00 AM
Ivan Dcruz
Ivan Dcruz - avatar
2 Answers
+ 4
Tags that needs a closing tag works as container for other self closing and non self closing tags. For example, div needs a closing tag so it can contain other div or img tags <div> <p>Closing tag</p> <img src="img.jpg"> <div>
10th May 2020, 4:37 AM
Raj Chhatrala
Raj Chhatrala - avatar
+ 3
It depends upon usage of tag.... img have limited attribute and it only use to display images, and br tag is not for line break, there and requirement to put any content in them.... But vedio have various source for different extension of vedio which are it's content and it also have attribute like control, loop etc.... In short, If tag needs content to display, it will have ending tag.... else if it have attribute, then it will be self closing tag.....
10th May 2020, 3:25 AM
DeWill
DeWill - avatar