简体   繁体   中英

Do I need to use title=“” in this situation of HTML5?

When defining a title or alt to an anchor tag, which is valid HTML5?

Is it best to define both, or only one?

Does it affect SEO at all?

in HTML, even from version 4, the title attribute is valid for almost all elements. alt is different in that it's only valid for images, the idea being to provide a text only alternative version of the image, which would be useful to people with visual impairment (as they'd be able to hear their browser read the text)

It's good practice to provide an alt attribute for images, even if you're going to leave an empty string ( "" ). The alt attribute helps improve accessibility for screen readers since the user most likely can't see the image with which it's associated. The title is less useful for accessibility purposes but is still a good practice to get into.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM