简体   繁体   English

在HTML5的这种情况下,我是否需要使用title =“”?

[英]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? 在为锚标记定义标题或alt时,哪个是有效的HTML5?

Is it best to define both, or only one? 最好定义两者,还是仅定义一个?

Does it affect SEO at all? 它会影响SEO吗?

in HTML, even from version 4, the title attribute is valid for almost all elements. 在HTML中,即使是版本4, title属性也适用于几乎所有元素。 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) alt不同之处在于它仅对图像有效,其目的是提供图像的仅文本替代版本,这对视力受损的人有用(因为他们能够听到他们的浏览器阅读文本)

It's good practice to provide an alt attribute for images, even if you're going to leave an empty string ( "" ). 最好为图像提供alt属性,即使您要留下空字符串(“”)也是如此。 The alt attribute helps improve accessibility for screen readers since the user most likely can't see the image with which it's associated. alt属性有助于提高屏幕阅读器的可访问性,因为用户很可能无法看到与其关联的图像。 The title is less useful for accessibility purposes but is still a good practice to get into. 标题对于可访问性目的而言不太有用,但仍然是一个很好的实践。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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