Jump to content

What's the correct <img /> or <img>?

Recommended Posts

What is the correct format for the non-pair tag like img or link in HTML5?


In some sites I've read <img src="" />, with the slash at final, but in other sites (like w3schools) the format is <img src="" > without the slash.


It works in both cases but I think there should be only one right way.



Edited by Trimax
Link to post
Share on other sites

XHTML closes empty elements with a slash, HTML does not.


The same goes for elements such as <br />, <link /> and <input type="button" />

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...