- 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?
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. 👍
+ 1
Both ways are same and they don't create any error whether you choose to use a slash or not.
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.