Quarter Life Crisis

The world according to Sven-S. Porst

« FootballMainDirty Boulevard »

Spanned

212 words

One thing that frequently annoys me about HTML is that you cannot arbitrarily nest tags. In particular, some of the tags are considered ‘inline’ while others are considered to be ‘block’. And nesting something ‘block’ into something ‘inline’ is illegal.

Thus, for example on our home page there are items which contain the name, icon and description of an application. My initial plan was to use HTML along the lines of

<img src="..." alt="...">
<div class="name">...</div>
<div class="description">...</div>
for this. But as everything is supposed to be a clickable link, I wanted to wrap all of it into an anchor tag. With divs being ‘block’ elements and a being an inline element, this doesn’t result in (valid) HTML, though, according to our beloved validators.

Of course in this case the problem is easily solved by replacing the divs by spans with the addition of display:block; to your style sheet for those spans. But what about a situation where you have something like

<h3>...</h3>
<img src="..." alt="...">
and want a single link to include both? You can’t do it, you will have to use two links instead and do
<h3><a href="...">...</a></h3>
<a href="..."><img src="..." alt="..."></a>
instead which is a bit clumsy (and doesn’t generally give the same result either).

April 10, 2007, 2:30

Add your comment

« FootballMainDirty Boulevard »

Comments on

Photos

Categories

Me

This page

Out & About

pinboard Links

People

Ego-Linking