Jump to content

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


Trimax

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.

 

Thanks!

Edited by Trimax
Link to comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...