简体   繁体   English

编号进度条的语义HTML标签

[英]Semantic HTML tags for numbered progress bar

What would the most relevant HTML tags be for a numbered progress bar such as: 对于编号的进度条,最相关的HTML标签是什么:

(1) Step 1: do something (2) Step 2: do something else (3) Step 3: complete (1)步骤1:做某事(2)步骤2:做其他事(3)步骤3:完成

I considered using an <ol> but in this case, the '1', '2', '3', will need styling. 我考虑过使用<ol>但是在这种情况下,'1','2','3'需要样式。

1:做某事,2:做其他事,3:完成

Also to indicate which step the user is currently on. 还可以指示用户当前正在执行的步骤。

As you've already decided, an ordered list is the most semantic way to show a progress bar. 正如您已经决定的那样,有序列表是显示进度条的最语义的方式。 Unfortunately there isn't a specific HTML element or attribute for "current step" or anything similar (I wish I knew why!). 不幸的是,没有用于“当前步骤”或类似内容的特定HTML元素或属性(我希望我知道原因!)。 So you'll need to make something yourself. 因此,您需要自己做一些事情。 The simplest way I've used before is to use an image of the step number with an alt attribute, eg 我以前最简单的方法是使用带有alt属性的步骤编号图像,例如

<li><img src='step1.png' alt='Step 1: Current step'>Do something</li>

But you could use visually-hidden text instead. 但是您可以改用视觉隐藏的文本。 The image would need to be visually distinct from the other steps so that colour-blind users are informed as well. 图像在视觉上必须与其他步骤区分开,以便色盲用户也能得到通知。

Probably nothing more semantic currently than: 当前可能没有什么比这更有意义的语义了:

<ol>
 <li class='currentStep'>
  <span>1</span> 
  <span>do something</span>
 </li>
 <li>
  <span>2</span>
  <span>do something else</span>
 </li>
</ol>

Semantically I agree with the use of ol but I believe you can achieve the desired effect with a bit of css and use of data-attributes 在语义上,我同意使用ol但是我相信您可以通过使用一点CSS和使用data-attributes来达到预期的效果

The markup would look something like this 标记看起来像这样

<ul>
 <li data-step="1">Do something</li>
</ul>

Here's a sample of the implementation: http://jsbin.com/gifisireku/edit?html,css,output 以下是实施示例: http : //jsbin.com/gifisireku/edit?html,css,output

The benefit of using this is you can have clean and accessible markup which is great for SEO as well ;) 使用它的好处是您可以拥有干净且易于访问的标记,这对于SEO也是很好的;)

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

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