制作一个<pre> tag more accessible

时间:2018-04-30 04:41:48

标签: html accessibility semantic-markup screen-readers pre

In our blog, we're showcasing blocks of code in <pre> tags and we want to make them more accessible.

For now, a screen reader would read:

Here is our code [...]
import.org.whatever.i.dont.understand.this.is.too.bad etc

What would be great would be to have a wee announce like:

Here is our code [...] Block of Java code [...] > import.org.whatever.i.dont.understand.this.is.too.bad etc

so that the user knows what's going to follow.

How can we do this properly?

1 个答案:

答案 0 :(得分:1)

  

我们怎样才能正确地做到这一点?

您必须为Java代码使用HTML5 code标记,并且您希望每个人(不仅是具有屏幕阅读器的人)都可以访问您的网站,请在说明中键入Java一词:

Here is our Java code:
<code>import.org.whatever.i.dont.understand.this.is.too.bad</code>