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
Matthew Landers
144 PointsBasic src img question
Hello,
I am having difficulty getting my Smells Like Bakin logo to display.
My index.html file is in a folder. Also in that folder is another folder called Smells Like Bakin 1
In the Smells Like Bakin 1 folder is another folder called img
In the img folder there is a logo.gif file
The logo.gif is the image I want to display.
If someone could explain what is incorrect about the below code, it would be very much appreciated.
<img src="Smells Like Bakin 1/img/logo.gif" alt=Smells Like Bakin'>
Thanks in advance for your help.
3 Answers
Elliott Frazier
Courses Plus Student 9,647 Pointsyou need to remove the single quote from the end of the alt attribute. when wrapping quotes around an attribute's value you can use either double or single quotes interchangeably, so when you added the single quote/apostrophe to the end of " bakin' " it confused the browser because it thought you where opening a quote without closing it. you can use character sets to display apostrophes with it's entity name ' if you like.
Matthew Landers
144 PointsHey Elliott,
That didn't seem to do it.
Elliott Frazier
Courses Plus Student 9,647 PointsThis doesn't work?
<img src="SmellsLikeBakin1/img/logo.gif" alt="Smells Like Bakin">
Matthew Landers
144 PointsFor some reason it is still showing that broken image.
Elliott Frazier
Courses Plus Student 9,647 PointsTry it with the spaces now.
<img src="Smells LikeBakin 1/img/logo.gif" alt="Smells Like Bakin">
Matthew Landers
144 PointsMy apologies Elliot. I have discovered the source of the issue.
When I downloaded the images they were in a zipped folder. When I moved the images to a regular folder it displayed.
Thanks again.
Elliott Frazier
Courses Plus Student 9,647 PointsNo problem! I'm glad you have it working. :)
Elliott Frazier
Courses Plus Student 9,647 Pointsyour alt Attribute ends with a single quote instead of a double like it started with.
Matthew Landers
144 PointsThanks for your response Elliot.
That did allow for something display, although it shows a broken image as opposed to the logo.
Marshall Wells
2,044 PointsI wonder if it has to do with the fact you have spaces in the folder name? Id try it with the spaces taken out just to see if thats the problem or you might have to double quote it like ""Smells Like Bakin 1"/img/logo.gif" i think you typically want to use underscores instead of spaces in file names and folder names
Matthew Landers
144 PointsThanks Marshall. I tried removing the spaces but still no luck.
Below is the full code. This might bring additional insight I may have omitted.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Smells Like Bakin' Cupcake Company</title>
</head>
<body>
<img src="SmellsLikeBakin1/img/logo.gif" alt="Smells Like Bakin'">
</body>
</html>
Matthew Landers
144 PointsMatthew Landers
144 PointsSorry the code did not paste. Here it is:
<img src="Smells Like Bakin 1/img/logo.gif" alt="Smells Like Bakin'>