Correct closing or self-closing tags in HTML5

I have a question related to closing HTML self- closing tags .

Which is more true?

1. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
2. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Also, if anyone has a good alternative for this tag <meta>, for example:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />
OR
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

This article has helped me something.

I use <!DOCTYPE html>for my document type.

+4
source share
3 answers

It depends entirely on your DOCTYPE: self-closing tags are required to comply with the XHTML standard. HTML4 and HTML5 do not require self-closing tags.

+3
source

In it is HTML5not necessary to close certain HTML tags ... (but some do)

w3.org:

8.1.2.1
...
...
6) , void, , "/" (U + 002F). void, .

+3

, - , [ HTML 4/5]. , # 3 , , .

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<img src="http://images.wisegeek.com/young-calico-cat.jpg" alt="Smiley face" height="42" />
0
source

Source: https://habr.com/ru/post/1547996/


All Articles