简体   繁体   English

使用屏幕阅读器文本的优点

[英]Advantages of using screen reader text

I have seen some web templates that have html tags named Screen Reader Text like bellow: 我看过一些Web模板,它们的HTML标签名为Screen Reader Text ,如下所示:

<label for="name" class="screen-reader-text">Name:</label>

And its CSS will be: 其CSS将是:

.screen-reader-text {
    position: absolute;
    top: -999em;
    left:-999em;
}

But nothing is showed in my PC browser. 但是我的PC浏览器没有任何显示。 What is it? 它是什么? Regards. 问候。

Visual browsers will hide that content since the CSS essentially places it off of the screen. 可视浏览器将隐藏该内容,因为CSS实质上将其放置在屏幕之外。 Screen readers will ignore that CSS and read the content normally. 屏幕阅读器将忽略该CSS并正常阅读内容。 Basically, this site is attempting to make the page visually appealing while making is accessible to visually impaired users. 基本上,该站点试图使页面具有视觉吸引力,同时使视障用户可以访问该页面。

The tag here is the label tag. 这里的标签label标记。 The element is defined as belonging to the class screen-reader-text . 该元素被定义为属于screen-reader-text There is no magic in the name. 这个名字没有魔术。 It is just an assigned name, and could be foobar too. 它只是一个分配的名称,也可以是foobar The style sheet defines that an element in that class be positioned outside the browser window. 样式表定义了该类中的元素位于浏览器窗口之外。

This is bad practice, since label markup and labels of controls are useful to all users, not just users of speech browsers, which ignore the attempts to place something off screen. 这是不好的做法,因为label标记和控件的标签对所有用户有用,而不仅仅是语音浏览器的用户,因为语音浏览器会忽略将内容放置在屏幕之外的尝试。

There could be special reasons for the coding, but they cannot be guessed from the information given. 编码可能有特殊原因,但不能从给出的信息中猜测出来。

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

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