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="" /> 

    1 answer 1

    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.

    • I ask about the tags that do not have a closing tag. - Heidel
    • @Heidel: look at the response update - VladD
    • @Heidel: for tags that do not have a closing one, it should be all the same. - VladD