Quick info on self closing tags…

Is it <input> or <input/> ?
I’ve seen both and was wondering which was correct.
Thx!

1 Like

According to MDN: " Self-closing tags (<tag />) do not exist in HTML"

I don’t know if that is technically correct, but the point is that you don’t need the forward slash. It is a holdover from other standards but HTML doesn’t use it and I would recommend you don’t either.

In HTML, elements that only have one tag are called void elements. It’s just an element that can’t have anything inside of it, such as text or other elements. The forward slash at the end is not required. But it also won’t cause any harm if you do add it since all browsers will accept that.

Personally, I never use the forward slash and I think it is ugly to do so, but I’m sure there are others who disagree.

2 Likes

I agree - I think it’s pretty ugly too. Good to know and thank you. I have already been using them without the slash and was quite alarmed to see some with it, so this is relieving.
Good to see you here again, @bbsmooth !

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.