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

HTML How to Make a Website Creating HTML Content Build the Footer

Hernan Martin Demczuk
Hernan Martin Demczuk
1,264 Points

Which 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

I 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.

It's the same.

Generally you use the first in programming phase, and the second in the final (production) of your website.

Hi 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