将 <article>s 放入 <li>s 是一个好习惯吗? [英] Is it a good practice to put <article>s inside <li>s?

查看:29
本文介绍了将 <article>s 放入 <li>s 是一个好习惯吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常在博客的首页上,有几篇最近的博客文章,每篇博客文章都是一篇

.通常博客评论也使用
标记.

我的问题是:将那些

放在
  • 中是否是一个好习惯?我曾经这样做是因为在我自己的解释中,那些
    以一定的数量/数量的方式一起呈现.因此,在列出一定数量/数量的元素时,

        是最佳选择.

        但是,也许我需要重新考虑我的解释,因为将

        s 放在
      1. s 中似乎是对 s 的误用.li>.而且我还想考虑可访问性.我不确定这样做是否会导致对辅助技术的混淆.

        解决方案

        问题真正归结为:什么是列表?如果是文章列表,则应使用

      2. 将其标记为此类.屏幕阅读器用户的优势在于屏幕阅读器可以使用语义标记来传达有用的信息.例如,通知用户他们刚刚访问了5 个项目的列表",这有助于他们了解内容的组织方式以及内容的数量.

        也就是说,如果列表中的每个项目都很长或包含具有大量嵌套元素的复杂内容,我同意@IanY 这可能会令人困惑,因为这样用户就很难跟踪他们所在的位置清单.

        当内容块相对较大时,如果视力正常的用户不太可能查看该内容并将其识别为项目列表,则不应使用

      3. .如果您使用
        和标题来标记文章标题,则可以提供足够多的语义来方便屏幕阅读器用户进行导航.

        Typically on the front page of a blog, there are several recent blog posts, and each blog post is an <article>. And usually blog comments are markuped using <article>s, too.

        My question is: Is it a good practice to put those <article>s inside <li>s? I used to do that because in my own interpretation those <article>s together are presented in a way of a certain amount/quantity. So when it comes to listing a certain amount/quantity of elements, <ul> and <ol> are the best choices.

        However, maybe I need to reconsider my interpretation because putting <article>s inside <li>s seems to be a misuse of <li>. And I also want to take accessibility into account. I'm not sure if doing that causes confusions to assistive technologies or not.

        解决方案

        The question really comes down to: What constitutes a list? If it's a list of articles, then it should be marked up as such using <li>. The advantage for screen reader users is that screen readers can use the semantic markup to communicate useful information. For example, informing the user that they've just landed on a "list of 5 items" helps them to understand how the content is organized, and how much of it there is.

        That said, if each item in the list is very long or contains complex content with lots of nested elements, I agree @IanY that this could be confusing, as it then becomes difficult for users to keep track of where they are within the list.

        When blocks of content are relatively large, if a sighted user isn't likely to look at that content and identify it as a list of items, then you shouldn't use <li>. If you use <article> and a heading to mark the article title, that provides a sufficient amount of semantics to facilitate navigation for screen reader users.

        这篇关于将 &lt;article&gt;s 放入 &lt;li&gt;s 是一个好习惯吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆