向 img 标签添加强烈强调。语义学

发布于 2024-08-19 02:05:53 字数 201 浏览 10 评论 0原文

我实际上正在编写一个网站,我产生了疑问。我有一个图像列表(这是一个艺术家作品集,所以应该是图像),其中一些带有“精选”徽章。将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

埋情葬爱 2024-08-26 02:05:53

我认为那很好。您可能已经这样做了,但您需要确保 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"

柳若烟 2024-08-26 02:05:53

我认为这样做是完全可以接受的,而且是更好的选择。

I think that it would be perfectly acceptable to do this and preferable.

删除会话 2024-08-26 02:05:53

首先,我认为 HTML 4 规范允许这样做。问题是,你能依赖浏览器会用它做什么吗?我不会冒险这么做。

但至少,在许多浏览器中,您可以附加格式,

strong img {
    /* mark up for the featured image */
}

然后这应该适用于所有支持它的浏览器。

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

strong img {
    /* mark up for the featured image */
}

And this should then work for all browser that support it.

萌吟 2024-08-26 02:05:53

我不会在图像上使用强标签,我不确定为什么它会更好,因为它仅指“强调”文本:听觉用户代理可能会使用不同的声音来强调,这对于图像来说毫无意义。

你为什么不直接使用一个类呢?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文