开发者

Are login/signup links a semantic use-case of HTML5 <menu>

开发者 https://www.devze.com 2023-03-27 11:18 出处:网络
Live Example HTML5 <menu> element HTML5: <menu type=\"list\"> <li><a href=\"/signup/\"> Sign Up </a></li>

Live Example

HTML5 <menu> element

HTML5:

<menu type="list">
  <li><a href="/signup/"> Sign Up </a></li>
  <li><a href="/login/"> Log In </a>开发者_JAVA技巧;</li>
</menu>

I want to add a signup / login menu to my website.

  • Would using <menu> be semantic?
  • Should I use <ul> instead?

Edit: I'm using semantic HTML5. Browser support is irrelevant.


As I'm sure you're aware:

The menu element represents a list of commands.

It really just depends on how you define "list" and "commands." Are "Login" and "Sign up" commands? Or are they list items? Personally I think they're commands. A list (ul or ol) is more akin to something longer, two items just don't seem to make a list, to me. Login and Sign up seem like commands because they're what Stephen Krug, in Don't Make Me Think calls "Utilities":

Utilities are links to important elements of the site that aren't really part of the content hierarchy.

These are contrasted with what he calls "Sections":

links to the main sections of the site: the top level of the site's hierarchy [navigation]

This makes sense semantically: You use <nav> for Krug's "sections" (navigation) and <menu> for utilities or commands (Log in, Sign Up, Search, etc.)


I don't think it's going to matter too much. There are a lot of options you can choose, even the new <nav> tag. But an unordered list certainly isn't going to wreak havoc on your code or not pass HTML5 validation.

I still use unordered lists for my navigations. This includes websites with a top heading nav, sidebar, and footer links. But speaking in semantics, I would recommend the nav element over menu.

0

精彩评论

暂无评论...
验证码 换一张
取 消