图片标题属性或链接标题属性还是两者? [英] Image title attribute or link title attribute or both?

查看:280
本文介绍了图片标题属性或链接标题属性还是两者?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个页面上的图像列表,它们被包装在链接中。所以,当你点击一张图片时,你会进入一个显示较大图片的页面。



这里应该如何处理标题标签?



我是否将图像标题放在图像和链接上,或者只是图像?如果标题与alt属性相同,是否重要?

 < a title =image descriptionhref =#>< img title =image descriptionalt =图片说明src =image.jpg>< / a> 


解决方案

HTML5定义了 alt 用法。请参阅一个链接或按钮,只包含一个图片


作为超链接的 a 元素或按钮元素没有文本内容,但包含一个或多个图像,在 alt 属性中包含文字,这些文字一起表达了链接或按钮的用途。


因此,您的 alt 属性内容可能包含类似于打开更大版本...的内容。



(您可能也对我的回答对UX SE的问题感兴趣: ALT文本是一个图像,也是一个链接?






你永远不应该有相同的内容 alt title 。请参阅一般准则(来自HTML5的W3C候选推荐标准)更新):在HTML5的W3C推荐标准中,本节已更改,并且不再包含该报价。):


这个推论是, alt 属性的值不能包含可以被认为是图片标题,标题,或传说。它应该包含用户可以使用的替代文本,而不是图片;它并不意味着补充图像。 标题属性可用于补充信息。



Let's say I have a list of images on the page, that are wrapped within links. So when u click an image it gets you to a page that displays the larger image

How should I handle title tags here?

Do I put the image title on both the image and the link, or just the image? Does it matter if the title is the same as the "alt" attribute?

<a title="image description" href="#"><img title="image description" alt="image description" src="image.jpg"></a>

解决方案

HTML5 defines guidelines for alt usage. See the section "A link or button containing nothing but an image":

When an a element that is a hyperlink, or a button element, has no text content but contains one or more images, include text in the alt attribute(s) that together convey the purpose of the link or button.

So your alt attribute content could include something like "Open larger version of …".

(You may also be interested in my answer to the question on UX SE: What should the ALT text be for an image that is also a link?)


You should never have the same content for alt and title. See the general guidelines (from the W3C Candidate Recommendation of HTML5) (Update: In the W3C Recommendation of HTML5, this section got changed, and it no longer contains that quote.):

A corollary to this is that the alt attribute's value should never contain text that could be considered the image's caption, title, or legend. It is supposed to contain replacement text that could be used by users instead of the image; it is not meant to supplement the image. The title attribute can be used for supplemental information.

这篇关于图片标题属性或链接标题属性还是两者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆