Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should you, or should you NOT, close void elements/self-closing tags with a forward slash?

Tags:

html

xhtml

tags

Thanks for taking the time to read this.

I have looked at all of the directly relevant questions and answers, and as well as the indirect ones, regarding this topic. And thus far, as far as I can tell, they have not answered the question specifically how I have asked it. Though this is a very fine line here and this question will likely get posted as a duplicate but regardless If I could get the proper answer from any of you I would be immensely grateful.

As of this moment any website that I develop is should I, or should I not, close my void elemnts/self-closing tags. Is this possibly a best practice? E.g:

<br>
<br />
<img>
<img />
<hr>
<hr />
<meta>
<meta />

Here are some other questions that were asked and are similar. Remember. SHOULD I DO THIS? This is what I need to know. Thanks.

Are (non-void) self-closing tags valid in HTML5?

Properly closing or self-closing tags in HTML5

Self-closing tags (void elements) in HTML5

Properly closing or self-closing tags in HTML5

My main concern is that by closing these tags like so <br /> that it may make the tag incompatible with certain browsers or platforms. Is this true?

Anyway, as always thank you for your time and your replies. Have a great day and veterans day weekend.

like image 872
DeveloperDan Avatar asked Nov 10 '17 22:11

DeveloperDan


1 Answers

According to conventions: https://dev.w3.org/html5/html-author/#notes,-tips-and-warnings

6.1.2.2 Void Elements 

You should not use slash at the end.

like image 128
Dawid Kisielewski Avatar answered Nov 17 '22 01:11

Dawid Kisielewski