向 img 标签添加强烈强调。语义学
我实际上正在编写一个网站,我产生了疑问。我有一个图像列表(这是一个艺术家作品集,所以应该是图像),其中一些带有“精选”徽章。将 img 包装到强标签而不是使用 class="featured" 在语义上是否正确?它会强烈强调图像吗?
阅读 W3C 规范,它将 Strong 和 em 称为文本级语义,但我不确定像 img 这样的媒体会发生什么。
太感谢了。
I'm actually coding a website and a doubt came to me. I have a list of images (it's an artist portfolio, so it should be images), some of which have a "Featured" badge. Is it semantically correct to wrap the img into a strong tag instead of using a class="featured"? Will it add strong emphasis to the image?
Reading the W3C spec., it refers strong and em as text-level semantics, but I'm not sure what happens with media like img.
Thank you so much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为那很好。您可能已经这样做了,但您需要确保 ALT 文本描述了强调图像的原因。例如 alt="男人与狗 - 精选"
I think that's fine. You may already be doing this, but you need to make sure that the ALT text describes why the images has been emphasized. Eg alt="man with dog - featured"
我认为这样做是完全可以接受的,而且是更好的选择。
I think that it would be perfectly acceptable to do this and preferable.
首先,我认为 HTML 4 规范允许这样做。问题是,你能依赖浏览器会用它做什么吗?我不会冒险这么做。
但至少,在许多浏览器中,您可以附加格式,
然后这应该适用于所有支持它的浏览器。
First of all, I think the HTML 4 spec allows it. Question is, can you rely on what browser will do with it. I would not take my chances with that.
But at least, in many browsers you can attach formatting to
And this should then work for all browser that support it.
我不会在图像上使用强标签,我不确定为什么它会更好,因为它仅指“强调”文本:听觉用户代理可能会使用不同的声音来强调,这对于图像来说毫无意义。
你为什么不直接使用一个类呢?
I wouldn't use the strong tag on images, I am not sure why it would be preferable since it refers to 'emphasized' text only: an aural user agent may use different voices for emphasis, it would be pointless for images.
Why don't you just use a class?