- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
到目前为止,我的理解是 alt
属性是必需的,不应留空。这似乎在现有问题中得到证实,例如 this one .
然而,在阅读HTML spec今天,我注意到以下几点:
A single image can have different appropriate alternative text depending on the context.
In each of the following cases, the same image is used, yet the alt text is different each time. The image is the coat of arms of the Carouge municipality in the canton Geneva in Switzerland.
Here it is used as a supplementary icon:
<p>I lived in <img src="carouge.svg" alt=""> Carouge.</p>
它继续显示其他示例,其中包含各种 alt
文本,但在此(以及其他几个示例)中,缺少 alt
文本。
规范后面说(强调我的):
Except where otherwise specified, the alt attribute must be specified and its value must not be empty; the value must be an appropriate replacement for the image.
可以使用 alt=""
吗?如果是这样,什么时候这是可以接受的用途?如果图片不需要 alt
文本,它应该是 CSS 背景图片吗?
注意:这是基于 WHATWG HTML Living Standard,而不是 W3C HTML5 规范。
最佳答案
alt
属性为空通常,alt
属性是必需的;但是,在某些情况下,HTML 规范表示可以保留 alt
。属性的内容为空。 alt
属性是图像的文本等价物,这意味着只有当图像的含义已经被周围的文本封装时,它才应该为空。
重要的是将替代文本视为图像在不可用的情况下应传达的内容。如果图像可以通过围绕它的文本进行总结,那么它应该有一个空的 alt
。属性,因为冗余不会带来好处。
示例包括重复周围文本的流程图或图表。
如果要使用标题,该标题应包含为 title
元素或使用 <figcaption>
. alt
如果图表可以用页面上其他地方没有的信息来描述,则应该使用。规范说明了为什么应该避免这种重复:
Including the caption in the alternative text like this isn't useful because it effectively duplicates the caption for users who don't have images, taunting them twice yet not helping them any more than if they had only read or heard the caption once.
通常,规范建议 CSS background-image
用于此,但澄清在某些情况下,这可以通过标记来完成,例如诗歌旁边的绘画,或事件中的风景照片。在这些情况下,图像是内容,但只有当用户能够看到图像时,该内容才相关。
只有一张图片应该有 alt
文本,以避免向看不到图像的用户重复文本。
规范建议为此使用图像映射,但如果图像被切片,则必须有一个图像带有 alt
每个链接的文本。
alt
完全属性在某些情况下,替代文本未知或不必要,在这些情况下,alt=""
是不准确的,因为它暗示图像没有添加任何东西。 HTML 规范警告:
If there is even the slightest possibility of the author having the ability to provide real alternative text, then it would not be acceptable to omit the alt attribute.
但是,它承认在一些情况下 alt
可以省略。
alt
(link) 在某些情况下,例如盲人用户的博客或元数据不包含有用信息的照片共享网站,alt
可能是未知的。
在这些情况下,使用 title
属性或 <figcaption>
是必需的。虽然可能不知道图像的确切细节,但仍应包括一些解释性文字。在这种情况下,<figcaption>
是首选,因为
Relying on the title attribute is currently discouraged as many user agents do not expose the attribute in an accessible manner as required by this specification.
如果您编写的文档只会被少数已知收件人查看,并且已知所有收件人都能够看到图像,则 alt
属性可以省略。建议alt
无论如何都要包括在内,以防电子邮件或文档被转发。
如果图像不是内容,它可能应该是背景图像。 <img>
背后的基本原理分割与 background-image
, 查看 When to use IMG vs. CSS background-image?
关于html - 什么时候可以在 HTML 图像上将替代文本留空(如果有的话)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23526791/
表架构 DROP TABLE bla; CREATE TABLE bla (id INTEGER, city INTEGER, year_ INTEGER, month_ INTEGER, val I
我需要拆分字符串/或从具有以下结构的字符串中获取更容易的子字符串。 字符串将来自 window.location.pathname 或 window.location.href,看起来像 text/n
每当将对象添加到数组中时,我都会尝试更新 TextView ,并在 TextView 中显示该文本,如下所示: "object 1" "object 2" 问题是,每次将新对象添加到数组时,它都会覆盖
我目前正在寻找使用 Java 读取网站可见文本并将其存储为纯文本字符串的方法。 换句话说,我想转换成这样: Hello stupid World进入“ Hello World ” 或者类似的东西 Un
我正在尝试以文本和 HTML 格式发送电子邮件,但无法正确发送正确的 header 。特别是,我想设置 Content-Type header ,但我找不到如何为 html 和文本部分单独设置它。 这
我尝试了上面的代码,但我无法绑定(bind)文本,我怎样才能将资源内部文本 bloc
我刚刚完成了 Space Shooter 教程,由于没有 GUIText 对象,所以我创建了 UI.Text 对象并进行了相应的编码。它在统一播放器中有效,但在构建 Web 应用程序后无效。我花了一段
我有这个代码: - (IBAction)setButtonPressed:(id)sender { NSUserDefaults *sharedDefaults = [[NSUserDefau
抱歉标题含糊不清,但我想不出我想在标题中做什么。无论如何,对于图像上的文本,我使用了 JLabel 文本并将其添加到图标中。 JLabel icon = new JLabel(new Imag
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topi
我在将 Twitter 嵌入到我从 HTML 5 转换的 wordpress 运行网站时遇到问题。 我遇到的问题是推文不是我的自定义字体... 这是我无法使用任何 css 定位的 HTML 代码,我正
我正在尝试找到解决由于使用以下形式的代码而导致的冗余字符串连接问题的最佳方法: logger.debug("Entering loop, arg is: " + arg) // @1 在大多数情况下,
我写了这个测试 @Test public void removeRequestTextFromRouteError() throws Exception { String input = "F
我目前正在创建一个正则表达式来拆分所有匹配以下格式的字符串:&[文本],并且需要获取文本。字符串可能类似于:something &[text] &[text] everything &[text] 等
有没有办法将标题文本从一个词变形为另一个词,同时保留两个词中使用的字母?我看过的许多 css 文本动画大多是视觉的,很少有旋转整个单词的。 我想要做的是从一个词过渡,例如“BEACH”到“CHANGE
总结matplotlib绘图如何设置坐标轴刻度大小和刻度。 上代码: ?
我在容器 (1) 中创建了容器 (2)。你能帮忙如何向容器(1)添加文本吗?下面是我的代码 return Scaffold( body: Padding( padding: c
我似乎找不到任何人或任何人这样做过。我试图限制我们使用的图像数量,并想创建一个带有渐变作为其“颜色”的文本,并在其周围设置渐变轮廓/描边 到目前为止,我还没有看到任何将两者结合在一起的东西。 我可以自
我正在为视频游戏暗黑破坏神 2 使用 discord.py 构建一个不和谐机器人。其中一项功能要求机器人从暗黑破坏神 2 屏幕截图中提取项目的名称和属性。我目前正在为此使用 pytesseract,但
我很难弄清楚如何旋转 strip.text theme 中的属性来自 ggplot2 .我使用的是 R 版本 3.4.2 和 ggplot2 版本 2.2.1。 以下是 MWE 的数据。 > dput
我是一名优秀的程序员,十分优秀!