Blog van Jeroen van der Gun

HTML5 figure and details do not break in IE

26 November 2009, 23:31

While this blog ought to be written in Dutch, I'm going to make an exception today because I'll address a global issue in this post. It's about the future of the World Wide Web.

As the title suggests, I'm going to talk about the figure and details elements in HTML5, the next version of HTML. The contents of these elements consist of dt and dd elements: dt for the caption, dd for the actual content.

Recently this content model has been criticized because there appeared to be a styling flaw in Internet Explorer 6 and 7. To be precise, the style of the last dt or dd element was leaked to the parent because IE ignored the closing tags of dd and dt (as well as the unknown figure and details tags of course).

These were said to be "killing rendering issues". People suggested modifying the specification or even dropping the figure and details elements completely. People introduced workarounds using Conditional Comments, JavaScript, unclosed object elements and worse.

I conclude I am really awesome since I discovered much simpler solution that is valid HTML5, does not require JavaScript, does not require Conditional Comments and is very short. It's hard to believe that no one thought of my solution before.

You'll agree with me after I told you to put the details or figure element inside a div element. Yes, it's that simple! The closing div tag will effectively stop the style leek.

I've set up a demonstration for those who don't believe me. I successfully tested it in IE7. It also keeps working if the order of the dd and dt elements is reversed.

Now stop trying to get the HTML5 specification changed because the current specification is perfectly backwards compatible as you can see.

Reacties

Stuart
27 November 2009, 20:38
Nice solution, Jeroen - and the simplest are usually the best! :)
Mark Morgan
28 November 2009, 0:52
So, the HTML5 spec should be updated to require a DIV for this circumstance?

A workaround is still a break.
Jeroen van der Gun
28 November 2009, 1:11
No, the HTML5 specification should _not_ be changed. In the current specification, using a div element is allowed but not required. It does not raise any problem since the div element has no semantic meaning, so it isn't really a major hack.

In other words, as a webmaster, you are not required to write pages that are compatible with old versions of IE, it's just smart to do so if a large part of your target audience uses these versions.

Using a div element should not required by the specification - it shouldn't even be included in it - , it is just a practical tip to improve backward compatibility.
opt.
opt.
3 × 5 =

Lees ook

Feeds Blogbelevenisoptimalisatie

  1. Informatie over de auteur staat op mijn portfoliosite, met name in mijn profiel.
  2. Voel u vrij te reageren op artikelen. Gaat uw reactie niet over een specifiek artikel, dan kunt u het gastenboek gebruiken.
  3. U kunt meldingen van nieuwe berichten ontvangen via feeds: zie de instructies. Dit geldt voor zowel blogitems als reacties.
Blognavigatie: 10 9 8 7 6 5 4
Copyright © 2005-2010 Jeroen van der Gun, alle rechten voorbehouden.
Lees mijn disclaimer en privacyverklaring.
Alle pagina's van deze site zijn printvriendelijk.
W3C: XHTML 1.0 W3C: CSS level 2 Atom: Valid
Wat betekenen deze pictogrammen?