In HTML5, should the main navigation be inside or outside the
element?

前端 未结 5 1023
不思量自难忘°
不思量自难忘° 2020-12-22 15:30

In HTML5, I know that

5条回答
  •  不知归路
    2020-12-22 15:57

    It's a little unclear whether you're asking for opinions, eg. "it's common to do xxx" or an actual rule, so I'm going to lean in the direction of rules.

    The examples you cite seem based upon the examples in the spec for the nav element. Remember that the spec keeps getting tweaked and the rules are sometimes convoluted, so I'd venture many people might tend to just do what's given rather than interpret. You're showing two separate examples with different behavior, so there's only so much you can read into it. Do either of those sites also have the opposing sub/nav situation, and if so how do they handle it?

    Most importantly, though, there's nothing in the spec saying either is the way to do it. One of the goals with HTML5 was to be very clear[this for comparison] about semantics, requirements, etc. so the omission is worth noting. As far as I can see, the examples are independent of each other and equally valid within their own context of layout requirements, etc.

    Having the nav's source position be conditional is kind of silly(another red flag). Just pick a method and go with it.

提交回复
热议问题