JavaScript-dependent Behaviours
Recently, I’ve been inspired by Chris Coyer’s article about when, and when not to, use an anchor tag. Especially this quote made me think a lot about how I used to design some page elements.
“I think if you are going to put a href attribute on the anchor that actually does something even if JavaScript is disabled, then the anchor is the right choice. If the app is totally JavaScript dependent all behavior is attached via JavaScript, I guess it doesn’t really matter what element you use. Maybe it’s even better not to use an anchor since the behavior probably bears no resemblance to what anchor links do. You could probably talk me out of that though. The thing is, anchors give you (“for free”) lots of the visual functionality that you want with deep browser support.”
Following Chris Coyer’s advice, I’ve changed my approach to Javascript-dependent behaviours, as follows.
