“由于颜色对比度不足,用户可能难以阅读文本内容”错误
Chrome notify a contrast problem:
But the problem was on this element:
<h3> </h3>
The element seems avoidable but it's needed for it's height.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里的答案是利用 CSS 来增加高度,可以使用边距或填充,并完全删除空标题。
空标题实际上会导致几个问题:
如果您遇到主题/系统等需要空标题的问题,请在页面加载后立即使用 JavaScript 删除标题,或者更好的是,花点时间在源代码中找到有问题的行并添加一个那里有条件语句。
或者,如果您能够应用类,您甚至可以使用 CSS(OP 的情况似乎如此)。
visibility:hidden
会被屏幕阅读器忽略,但仍会占用空间。这不是最好的选择,但至少可以解决可访问性问题。The answer here would be to utilise CSS to add height, either with margin or padding and remove the empty heading entirely.
Empty headings actually cause a couple of issues:
If you have an issue where the theme / system etc. requires a heading that is empty then use JavaScript to remove the heading as soon as the page is loaded or better yet, take the time to locate the offending line in the source and add a conditional statement there.
Or you can even use CSS if you are able to apply classes (as seems to be the case for OP).
visibility: hidden
is ignored by screen readers but will still take up space. Not the best option but would fix the accessibility issues at least.“已解决”向元素添加 CSS 颜色属性:
在我的 CSS 中:
编辑 - 接收建议
正如指出 @slugolicious 和 @Sean 和 @GrahamRitchie 一个空的 H* 元素一样,它作为可访问性和 SEO 很糟糕。
我将应用一种不同的方法来消除空标题元素。
"Solved" adding a CSS color attribute to the element:
In my CSS:
EDIT - receiving suggestion
As point-out @slugolicious and @Sean and @GrahamRitchie an empty H* element it's bad as accessibility and SEO.
I will apply a different approach that will eliminate the empty heading elements.