Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Jonathan Kuhl
26,133 PointsIsn't it best practice to close an img tag? Ex: <img src="url" />?
This isn't my first HTML tutorial, but it's one of the more indepth ones I've come across and I'm still new enough that I need to start from the beginning. However, I've learned in other tutorials that an image tag should be closed, like <img src="url" />
I'm just asking for clarification, if we should be closing these tags or not.
2 Answers

Joachim Larsen
12,140 PointsHi!
You don't have to close the <img> tag in HTML, because it doesn't have any content (the image is only referenced in the tag's attributes). They are called empty elements, just like the <br> tag.
I believe the ' />' syntax comes from the more strict XHTML markup language: https://www.w3schools.com/html/html_xhtml.asp

Jonathan Kuhl
26,133 PointsAlright, thanks for the clarification.