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

Robert Lay
seal-mask
.a{fill-rule:evenodd;}techdegree
Robert Lay
Front End Web Development Techdegree Student 1,876 Points

If you add <figcaption> around <img>, is it best practices to remove the title attribute or include both?

In the video, the instructor removed the title attribute from the <img> tag when adding <figcaption>. I was wondering if it's a good idea to keep title to have both or if it is unnecessary and you just do one or the other? Thanks!

<figure> <img src="img/vr-space.jpg" alt="User experiencing space in VR" title="Virtual Reality users can explore far away places and feel as though they are right in the middle of the action."> <figcaption> Virtual Reality users can explore far away places and feel as though they are right in the middle of the action. </figcaption> </figure>

2 Answers

Pepe ToΓ±o
Pepe ToΓ±o
13,815 Points

In this case you are free to delete the tittle parameter from figure tag because of figcaption existance. In practice both are a way to describe an object in the DOM, but the main difference is that the title parameter is not always visible, it only appears when you hover an html control with your mouse; figcaption is always visible and is useful just for an image you want to show permanently with its description.

Stephen Bolger
Stephen Bolger
4,505 Points

If you add a caption to an image using <figure> and <figcaption>, you can remove the title attribute. Your image should still include an alt tag.