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 trialJackie Santana
7,403 Pointsi"m confused about the href attribute, i can't ever seem to get this right.. in which order should i place the href?
i"m confused about the href attribute, i can't ever seem to get this right.. in which order should i place the href? before the "img src"? or after the "alt" or does it even matter
<!doctype>
<html>
<head>
<title>My trip to Spain</title>
</head>
<body>
<p><img src="images/spain.jpg"<a href="#top"> alt="A picture of me in Spain">
Here is a picture of me in Spain last summer!
<a>Go back to the top of the page.</a></p>
</body>
</html>
2 Answers
Jared Williams
5,650 PointsThe answer is neither. What you are doing is putting an anchor tag inside the <img>
tag which is not allowed in HTML. If you remove all the attributes you will see that you have something like this:
<!-- Bad example HTML -->
<img <a>>
The order of the elements (href, src, alt, class, style, etc.) on the tags don't matter, but which tags are inside or outside of another tag can be important.
The 3rd step of the challenge doesn't require you to change the <img>
tag at all. It simply wants you to add a href
attribute to the existing <a>
tag on the page.
Also, don't forget to close your <img>
tag with a self closing slash like this:
<!-- Remember to add a closing '/' on self-closing elements (not required, but good practice) -->
<img src="blablabla" />
Jackie Santana
7,403 PointsThanks bro! i see what your talking about.. it finally worked!