I love markup debates. Progressive enhancement and the power of CSS to take a single div
and turn it into almost anything the developer can imagine have made markup almost incidental. As I've said before here, I can mark up an entire page in abbr
s and still have it work just fine. SEO and accessibility are the last places where markup matters the way it used to, but technology seems to be progressing at such a rate that soon markup debates will be entirely philosophical.
When I learned HTML, it was off a print-out given to me by a white-haired high school IT guy. I think the tags it covered were h1-6
, b
, i
, img
, u/ol
, li
, and of course a
. Tables and framesets would come later - that handful of tags was considered at that time enough to put together a website. And really, that picture of HTML 101 at that point in time was fairly accurate. MTV's homepage was a black background with a huge jpg in the center. It took forever to load. The how had existed for a few years, but the why that would drive us to the point we're at now was still being invented.
I hadn't considered until recently that when I was introduced to the a
tag, it was introduced primarily as an anchor. Yeah, it was mentioned, you could also link to other stuff on the internet. But that involved typing in roughly fifty characters in those days, and URLs were highly subject to change because, well, you'd change your URL too if it were fifty damned characters long. And that's all assuming you'd found something else on the web you wanted to link to. Remember how in the mid-nineties people's links tended to all go to the same places? There wasn't a hell of a lot of compelling content out there that was easy to find. My first anchor tags were actually anchor tags. They passed you around the same page.
Now, of course, an anchor is probably the last thing the a
tag is likely to represent. We no longer need a tag to bookmark an area on the page - we can just use an element's ID. Even the concept of jumping to a location seems to be endangered. If I counted up the number of a
s in code I've written over the past couple of years that go to a URL vs. the number that initiate some JavaScript action, I think the ratio would be skewed toward the latter category. I love single page apps, so that may not be everyone's experience. But the anchor tag that might as well be a span
is certainly a hell of a lot more common than it used to be.
When we began progressively enhancing things and not calling it that, AJAX was just a way to avoid forcing your user to load an existing page. The link still went to that page and the users who had JavaScript turned off or whose browsers didn't support XHRs continued on as normal. You didn't have JS widgets, you had normal forms with certain fields enhanced or certain actions hijacked. Whatever you were doing was still heavily tied to the markup behind it, and what better markup for something that might, depending on the circumstances, take you to the next page of the wizard or magically pop the wizard open right then and there than an anchor tag?
And now? Shit, now it's a complete crapshoot whether someone with JS turned off is going to see anything upon visiting a site besides the company's fax number in Times New Roman. I can build a whole damn application with this between my body
tags:
<script>
$(document).ready(function(){ myStuff.init(); });
</script>
I generally have two types of a
tags in my markup now. Those with href
s are normal links. You click on them. There's a request to the server. A new page loads. Those without belong to JavaScript. Besides having no href
, they probably have no text between the tags. Until the JS runs, they more or less do not exist. They probably come from a JS template and never even appear on the page if JS is turned off. They're still anchor tags, but they might as well be any other damned thing. Hell, they could be made-up tags, since they have to be added via JavaScript and tarted up with thirty lines of CSS anyway. But anchor tags are how we take actions. It's been that way for twenty years or so. At first jumping around pages and between pages was the only action imaginable, then things changed, and changed again.
It's weird to me to think of them as anchors. Most of my anchors live in a purgatory of existence and nonexistence, not part of the DOM on page load, not leading to any concrete place, and yet representing a key or even primary action for the user in accomplishing some task. It's like hearing that default iPhone ringtone no one ever seems to change. At some point it was a useful metaphor. Now the metaphor's on its way to becoming as obscure as the ring of a rotary dial phone - I don't know about you, but I use more text messages than minutes and am following more people on twitter than I have in my phone book. Anyway, same with the anchor tag. Our telephones are becoming smaller netbooks, our HTML tags are becoming shorter div
s. I thought that was interesting.