HTML & CSS
Wouldn't it be better to simply omit the href attribute, it's not required after all. It seems the only reason to include the href is to force the hand cursor. Since this is possible with CSS is there any semantic or compatibility reason to include the href attribute at all?
Further to that: Should it even be an <a> tag or should I just use a clickable div/li/whatever the parent element is?
I'm interested in the best practice pros/cons of it.
The main reason for keeping the script activation in an <a> tag is to ensure that it is accessible for keyboard navigation and other assistive technology (including some mobile devices), which usually won't allow anything other than a link or input to receive focus, meaning that if you have the script activation on a <div> or other element, it will be impossible for people without a mouse or certain touch-screen devices to activate it.
I'm not aware of any advantage of including
href="#", although it may be that some devices won't allow keyboard-users to tab to an <a> that doesn't have an href.
What Stevie said ^
I'd only add that having a proper URL in the href to that content also helps people like me who like to right click > open in new tab. It does depend on what you are showing on click though.
This topic is now closed. New replies are no longer allowed.