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

rim woldetensae
rim woldetensae
1,161 Points

question about adding image code to HTML

<img src="sam.jpg" alt="sam"> What is wrong with this line of code? the website is saying that I need to add the alt in front of the sam.

It's not entirely clear what you're referring to, however, your code is syntactically fine. Could you share the website in question?

3 Answers

Your issue is that it is expecting a capitalized Sam in your alt text. Using the lowercase results in a different message returned from the challenge Bummer! The 'alt' attribute of the <img> element needs to be set to "Sam"! Set it like this: <img src="sam.jpg" alt="Sam"> which also provides a solution and explanation to the problem.

Trevor Johnson
Trevor Johnson
14,427 Points

You shouldn't need to put the alt in front. Is your picture showing up at all? Here is an example of an img tag that works correctly on something that I have done.

<img src="img/cliff.jpg" class="img img-rounded" alt="cliffs">
Trevor Johnson
Trevor Johnson
14,427 Points

Make sure you specify the path so that your image can be found. If it is not in the same folder as your index file, then you need to specify the folder, and then the image. If you need to go outside of your current folder into a new folder you need to do start it off with ../ which tells it to go up out of its current folder, and into where you specify.

Example:

<img src="../img/cliff.jpg" class="img img-rounded" alt="cliffs">