- 1

Why do we not write slashes right before the closing[ > ] of some self closing tags?

Some people say that every self closing tag should be written like this: <img/> But on solo learn, some tags like 'link' tag isn't written like <link/> Does this create an error without a slash?

10th Jun 2019, 7:31 AM
Mousin Ahanger
Mousin Ahanger - avatar
3 Respostas
+ 2
I'm pretty sure it is optional. I don't use the slash, and it has never thrown an error for me. 👍
10th Jun 2019, 7:35 AM
River
River - avatar
+ 1
Both ways are same and they don't create any error whether you choose to use a slash or not.
10th Jun 2019, 10:35 AM
Giorgos Mariettakis
Giorgos Mariettakis - avatar
0
HTML5: the slash is optional. HTML4: the slash is technically invalid. However, it's accepted by W3C's HTML validator. XHTML: The slash is REQUIRED.
11th Jun 2019, 7:49 AM
Chris Coder
Chris Coder - avatar