I want to create an action menu to trigger some actions on a single page application and I wonder what’s the most appropriated html5 tag for this?
I know the nav tag but it seems more suited for navigation than actions.
Should I use a simple div tag or is it a more semantical tag?
There is no element designed for the purpose in HTML5 as recently approved by the W3C. There was a menu
element (or, rather, the old menu
as completely revamped) in drafts, but it was dropped due to lack of implementations; it’s still in HTML 5.1 drafts and might become useable some day.
You can use just a sequence of button
elements, or you can wrap them in a div
element if this is useful for styling or scripting, and some people would favor a ul
wrapper. But asking which is “best” is like asking which food is best.
What you should be asking is which approach is most practical for programming and styling and for accessibility (though accessibility is here mainly a matter of adding ARIA attributes), with the constraint that it should work across all imaginable browsers. This depends on the context and type of the menu, the application as a whole, etc.