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 trialHernan Martin Demczuk
1,264 PointsWhich one is better according to best coding practices?
I see in this example that he uses two different ways when links an image:
<a href="img/numbers-09.jpg">
<img src="img/numbers-09.jpg" alt="">
</a>
and this:
<a href="img/numbers-09.jpg"><img src="img/numbers-09.jpg" alt=""></a>
I know this might depends on the person but is there any standard that says which one is the recommended when working with others and sharing your code?
3 Answers
Dustin Matlock
33,856 PointsI think for various reasons both would work. With larger document, the second version would perform better, but some might say the first one is more readable. I prefer the second version and think it's more readable — maybe only because I'm used to it. I posted it in another thread yesterday, but you might check out CSS Guidlines.
cesare
15,180 PointsIt's the same.
Generally you use the first in programming phase, and the second in the final (production) of your website.
Rich Bagley
25,869 PointsHi Hernan,
Personally I write mine inline as the second option but I'm not aware of any standard and both should be accepted.
Thanks
-Rich