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
lucas borowiecki
6,871 PointsWhy can't we just add an 'alt' attribute with 'captionText' to the $image? Why do we need to append a paragraph instead?
$image.attr("alt", captionText);
1 Answer
Steven Parker
243,656 Points These two things have very different purposes.
The text in an alt attribute would not be visible by default. It might become visible if the cursor is placed on the image, depending on the browser. But the primary use for alt is to be displayed when the image cannot be rendered for some reason, or to assist screen readers used by sight-impaired users.
On the other hand, a paragraph would always be visible.
Erik McClintock
45,783 PointsErik McClintock
45,783 PointsLucas,
Could you provide further context? A link to the video/challenge you're referring to, perhaps?
Erik