Is it semantically correct to nest an
element within a
  • element?
  • 后端 未结 2 871
    我寻月下人不归
    我寻月下人不归 2021-02-19 02:17

    using HTML5, would it be semantically correct to place an

    element within a
  • element. A situation where this would prove usefu
  • 相关标签:
    2条回答
    • 2021-02-19 02:30

      If it displays correctly in all implementations, I don't have any idea why it would be incorrect... HTML5 is meant to be flexible. Also, the documentation states:

      Contexts in which this element can be used: Where flow content is expected.

      Which looks to be the context of most elements available.

      0 讨论(0)
    • 2021-02-19 02:55

      There is nothing semantically incorrect about it, but it is not really necessary. The <ul> and <li> elements aren't really adding anything here, unless you are taking advantage of their default styling. Simply putting the <article> tags directly within the <section id="popular"> should be sufficient, and it reduces the complexity of your page as well as its size.

      To determine whether something is semantically correct and useful in HTML, ask yourself a few questions. Are you using each element for its intended purpose? For instance, it's not semantically correct if you use an <a> element for a button, as <a> is for hyperlinks, <button> is for buttons. Do you need each element you are using in order to convey all of the semantic information about your content (sections, headings, links, etc)? Is there anything meaningful that you intend to convey that isn't expressed by use of appropriate elements? Having lots of extra meaningless elements usually isn't harmful, but it adds clutter, and it may mean that there are semantic distinctions you are conveying visually but not encoding in a way that a screen reader or automated bot or browser that presented the information in a different format could make sense of.

      0 讨论(0)
    提交回复
    热议问题