Search code examples
htmlmarkupsemantic-markup

Twitters strange choice of markup


Viewing the Twitter source and i came across this. Strange to see an 'a' element without a href attribute. When the user clicks the link, all that happens is a pop up appears, it doesn't go to a different page, a la normal hyperlinks. Are they gaining any semantic kudos by using an 'a' element without a href or is this very very bad markup? Why would they not just use the span with an id?

<a id="new-tweet" original-title="New Tweet">
      <span>New Tweet</span>
</a>

Solution

  • An anchor is giving them the click appearance without having to style it in (e.g. cursor: pointer; cursor: hand;). It also allows them to make a more uniform feel across the page, instead of styling the "normal links" and ajax links separately.

    A's can be used without a href attribute (they used to be used to reference sections of a page (combined with the name attribute, then link.html#name) before IDs started being the more definitive way to reference portions of a page).

    I would say they're just keeping it "slim and trim".