Implied tags in the IE HTML parser and how that can be interesting.

I recently made the verbal error of saying that for the new BASE element changes in IE 7 you had to put your tag inside the HEAD element. Well, someone pointed out to me rather quickly that on Firefox you could just have a bare TITLE and BASE followed by some body content and away you go the page would validate and parse properly. Well, we do the same thing in IE, and it is called implied tags in HTML. There are some gotchas though.

First, I'll start with the trick... What in the heck is IE doing?
<HTML id="dumpInternals"><TITLE></TITLE><BASE href="foo"><BUTTON onClick="alert(dumpInternals.outerHTML)">Click Me!</BUTTON></HTML>

That is your boilerplate. When you click on your button there you'll find that IE is actually putting the TITLE/BASE in the implied HEAD of the document and then putting the BUTTON into the implied BODY. Good stuff, and the document is still perfectly valid. Issues can arise when you do this though because you aren't necessarily realizing what elements belong in the HEAD and which belong in the BODY and so you might terminate your HEAD enclosure early and put a bunch of random elements that don't belong in the BODY into the BODY.

This won't look right without your IE 7 Beta 1, since the BASE element is going to wrap a bunch of stuff, but you can get the gist. The below will show you that the second BASE ended up inside of the BODY. That isn't good, we don't look for BASE elements there and it won't get used. (Read my previous post on IE 6 behavior and you'll see that it used to get used because of some container magic, but not anymore, we are compliant).
<HTML id="dumpInternals"><TITLE></TITLE><BASE href="foo"><BUTTON onClick="alert(dumpInternals.outerHTML)">Click Me!</BUTTON><BASE href="foo"></HTML>

The set of implied rules has impacts in other areas as well. You can, for instance, end up using document.writeln to prematurely terminate your HEAD element and move a bunch of stuff out into the BODY. So, if you are doing inline document writes you should probably do them where you want the content to go. Writing the content out in script blocks that appear in the head is the wrong way to go about it. You could hook up to some events or have a container element that you write into, and that is acceptable, but with inline writes you could get unexpected behavior.

Recently I noticed a site that was doing a document.writeln in their HEAD element about half-way through the head content. End result? Well, the content got moved into the BODY element and the object model tree for the page was completely wrong. Good thing they weren't navigating the object model looking for stuff and good thing the extra META/LINK elements weren't being used as well. With a static parse of the page you wouldn't even notice these problems, but when DHTML becomes involved it can change the structure of your document on the fly and rewrite what the object model tree looks like.

I should back this up with some samples. I'll try and get those prepared shortly.

Published Tuesday, August 30, 2005 5:55 PM by Justin Rogers
Filed under:

Comments

# Browser Security News &raquo; Implied tags in the IE HTML parser and how that can be interesting.

# Browser Security News &raquo; Implied tags in the IE HTML parser and how that can be interesting.

# Browser Security News &raquo; Implied tags in the IE HTML parser and how that can be interesting.

Friday, August 24, 2007 11:18 PM by justin

# re: Implied tags in the IE HTML parser and how that can be interesting.

just wondering where you disappeared to?

Tuesday, September 04, 2007 1:58 AM by anothr user

# Anothr feed track -Justin Rogers

One new subscriber from Anothr Alerts

Thursday, January 24, 2008 6:46 AM by Webdesign

# re: Implied tags in the IE HTML parser and how that can be interesting.

just wondering where you disappeared to?

One new subscriber from Anothr Alerts

Friday, February 01, 2008 10:00 AM by Tweak Vista

# re: Implied tags in the IE HTML parser and how that can be interesting.

Monday, July 14, 2008 6:55 AM by handan

# re: Implied tags in the IE HTML parser and how that can be interesting.

I do is to web map programming, the map shows that this is the use of the mosaic map TABLE

eg:

<table>

<tr>

<td> <img src = "0_0.png" </ td>

<td> <img src = "0_1.png" </ td>

<td> <img src = "0_2.png" </ td>

</ tr>

</ table>

But when I open this page often do not show the picture, I must be in the picture of regional mouse click can show that, Firefox can be directly displayed without onclick, I do not know what it is because I am distressed!

# Browser Security News &raquo; Blog Archive &raquo; Implied tags in the IE HTML parser and how that can be interesting.

Pingback from  Browser Security News  &raquo; Blog Archive   &raquo; Implied tags in the IE HTML parser and how that can be interesting.

# Browser Security News &raquo; Blog Archive &raquo; Implied tags in the IE HTML parser and how that can be interesting.

Pingback from  Browser Security News  &raquo; Blog Archive   &raquo; Implied tags in the IE HTML parser and how that can be interesting.

# Browser Security News &raquo; Blog Archive &raquo; Implied tags in the IE HTML parser and how that can be interesting.

Pingback from  Browser Security News  &raquo; Blog Archive   &raquo; Implied tags in the IE HTML parser and how that can be interesting.

Wednesday, July 22, 2009 7:25 AM by Louis Vuitton

# re: Implied tags in the IE HTML parser and how that can be interesting.

Thursday, August 13, 2009 8:57 AM by Oris watches

# re: Implied tags in the IE HTML parser and how that can be interesting.

<a href="www.watchmvp.com/Oris.html">Oris watches</a>

Tuesday, September 15, 2009 2:52 AM by Excelwatch

# re: Implied tags in the IE HTML parser and how that can be interesting.

<strong><a href="http://www.excelwatch.com">I do not know what up with your post,can you tell me why there are so many radom words?</a></strong>

Wednesday, November 18, 2009 2:46 AM by come

# re: Implied tags in the IE HTML parser and how that can be interesting.

Hello, everybody. I am a new hand to be here. So nice to meet you all

Thursday, December 10, 2009 5:48 AM by a_poostchi

# re: Implied tags in the IE HTML parser and how that can be interesting.

Hi

I have a program that load a relatively large image file (satellite image), from a LAN.

To speed up loading process, I divide the original  image to smaller patches (e.g. 6x6 cm), and the application tile them appropriately. This works fine, but after each updated sat. image, I should divided it again, which is time consuming process.

I wonder how can I load desired patches from original image file?

Can you help me on this?

Thanks in advance.

Tuesday, February 09, 2010 4:44 AM by sale ed hardy

# re: Implied tags in the IE HTML parser and how that can be interesting.

  Hello ^^ I bookmarked this site. Thanks heaps for this!… if anyone else has anything, it would be much appreciated. Great website Super Pianoforte Links

http://www.ed-hardy.cc ed hardy on sale

Enjoy!

Leave a Comment

(required) 
(required) 
(optional)
(required)