Lessons in Understanding, via HTML

Poking through the W3C specification for HTML, I ran across a snippet of markup that was rendered something like the following:

<html
><body
><div
title="Title"
>Hello
</div
><div
>Hi again
</div
></body
></html
>

It was a little hard to mentally render this at first, so I decided to mess around.

First I added newlines in new places:

<
html
><
body
>
...

This didn’t work, for reasons that probably should have been obvious, but weren’t yet.

So I tried something else:

<html
Something here
><body
><div
...

Of course, this worked. So now my brain finally started to piece together what was happening.

HTML tags must support n arbitrary attributes after the tag declaration, which will contain whitespace as well. Any newline before the closing caret simply becomes extra white space. And my extra text was simply interpreted as additional attributes (albeit nonconforming).

So my crazy line of HTML could really just be understood in the following form:

<html attribute1 attribute1 >

which is really not at all that crazy.

On the other hand, when I had broken the lines apart after the opening caret, it was effectively rendering so:

< html > ...

which inserts white space before (or as part of?) the tag declaration, and is not supported — why would it need to be?

Pretty obvious when you get right down to it. But who would have known.


I learned the fundamentals of HTML over fifteen years ago and have used it continuously since, yet presented with a structure so different from how I was used to seeing it, my mind momentarily forwent all the lessons it knew so well and refused to contemplate the code I was presented with in view of that knowledge — it was just too different.

We run into this kind of situation in all sorts of contexts, sometimes as simple as code written by someone else. They may write great code but in a very different way, and we automatically reject it as “poor code” before we’ve even fully parsed it.

Even a normal sentence in natural language, coming from someone who views the world differently, may present us with a context so different from our own norms that we immediately jump to conclusions on the quality of what is being expressed, without really examining the semantics of the content.

If nothing else, when presented with something known but radically different, it behooves us to pause, think about the new information, play around with it, maybe even frame it in a familiar context. You might find it makes more sense than you thought it did.