Quick Tip - 19: Close Self-Closing Tags Without a Trailing Slash

May 30, 2014 | 0 Minute Read

For those of us who are used to working with XHTML this is going to seem a little odd but, with HTML5, we no longer need to add a trailing slash on self closing tags like images and inputs.

When using an img tag do you tend to set it up like this?

<img src="img.jpg" alt="Image" />

Well, that little trailing slash is no longer needed on self closing tags with HTML5. So you can now just do this:

<img src="img.jpg" alt="Image">

However, you don’t have to remove it, the spec says it is optional. Still you may want to consider it since it is now really just extra.