Do I still need to use the title attribute if my element has a `<figcaption>`?

自作多情 提交于 2019-12-10 16:34:22

问题


I have a piece of code like this:

<figure>
    <img title="An amazing image that I forgot to specify a url for"/>
    <figcaption>An amazing image that I forgot to specify a url for</figcaption>
</figure>

Is it necessary for me to specify the title attribute in addition to the figcaption element, and will not doing so result in SEO problems?


回答1:


Title attribute is mainly for providing a tooltip about what is that image or link about. Usually a the target's title.

In the images, using figcaption should be enough to overcome title attribute, hence you have a specific markup for describing the resource. Howver consider always using ALT attribute, even with figcaption.

This is because you can have more than one image in a figure.

For example, using 3 images for ilustrating progress on a process.

<figure>
<img src="img1.png" alt="The start of process. Subject is raw." />
<img src="img2.png" alt="Middle process. Subject is changing." />
<img src="img3.png" alt="End of process. Subject is completely transformed." />
<figcaption>Process steps, from left to right: raw subject, changing and changed subject.</figcaption>
</figure>



回答2:


Figcaption is enough. But you may need to specify title if you have to apply microformats like vCard: http://www.rachaelmoore.name/web-design/microformats/marking-up-contact-information-semantic-using-html5-microformat/



来源:https://stackoverflow.com/questions/3799285/do-i-still-need-to-use-the-title-attribute-if-my-element-has-a-figcaption

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!