5
When I was learning about HTML, I read that there are two types of tags, those that are necessary to 'close', (<tag></tag>
, ex: <div></div>
) and those with self closure (<tag/>
, ex: <img src="#"/>
), but I came across an inconvenience (or not), which is the following, closing or not my auto-closing tags, they work the same way, for example:
This
<img src="#" />
It’s the same as that (note that I didn’t close the tag with the bar)
<img src="#">
The same can be repaired at tags br
, input
, etc..
My question is, what’s the difference between closing those tags? What risks I take?
Just a complement to the above answer: in fact it is optional to put the closing bar in a self-closing tag (for example,
<br />
) but I find it interesting to differentiate self-closing tags from normal tags.– Rodrigo Rigotti