When using the doctype html5 <!DOCTYPE html> to write tags that do not have a closing tag, for example
<meta charset="utf-8"> <img src="" alt=""> Do I need to write a slash at the end?
<meta charset="utf-8" /> <img src="" alt="" /> When using the doctype html5 <!DOCTYPE html> to write tags that do not have a closing tag, for example
<meta charset="utf-8"> <img src="" alt=""> Do I need to write a slash at the end?
<meta charset="utf-8" /> <img src="" alt="" /> It is possible and so and so. However, for elements that may contain content, the result may be different, of course (imagine what will happen if you do not close <a> ). Here is a post on this topic with details (in English): http://tiffanybbrown.com/2011/03/23/html5-does-not-allow-self-closing-tags/
Update: here is a great answer on a brotherly resource :
On HTML 5,
<foo />means<foo>. Slash is just syntactic sugar for XML lovers. The slash syntax is supported, but it is not a “self-closing tag” at all! The difference is important because (at least in HTML syntax)<div />means<div>in HTML 5, not<div></div>, as in XHTML.
Source: https://ru.stackoverflow.com/questions/172156/
All Articles