I am going to ask this question, just because I want to understand the problem a little better.
I am working on a page that has a bunch of legacy JSP code that generates a huge amount of HTML form, using a table to hold the visible input fields. However, in many cases the JSP is rendering hidden inputs inside the <table>
but not inside of any <td>
which is invalid HTML structure. These types of HTML structure errors are all over the place in this page.
The JSP code for this page has been around for probably 10 years with no issues with this invalid HTML, and developers are well aware of this problem, but never had any reason to fix it. Now we are trying to make the page look more modern, and one of the things I am using is position:fixed.
Anyway - to demonstrate the issue here is a very simple HTML page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<html>
<head><style>.fixedTable { position: fixed; background-color:red; } </style></head>
<body>
<!-- this table gets an invalidly placed hidden input tag outside of the row -->
<table class="fixedTable" style="top:100px;left:100px;">
<input type="hidden" name="value" value="test">
<tr><td>Test 1</td></tr>
</table>
<!-- this table is properly structured -->
<table class="fixedTable" style="top:130px;left:100px;">
<tr><td><input type="hidden" name="value" value="test">Test 2</td></tr>
</table>
</body>
</html>
All browsers (except IE 7) shows 2 little red boxes on top of eachother 100px from the top and 100px from the left.
IE 7 gets the position of the first table (Test 1) completely wrong and puts it at the top left of the page. IE 8 is fine.
What is going on here?
Ok - sure, I could just fix the HTML structure - but I still want to know what is going on, then maybe I could figure out a work around without having to go through refactoring a huge amount of JSP code.
To add to the confusion...
Making one minor change to the style:
.fixedTable td { position: relative }
Now the text "Test 1" appears in the right place... but the red background is still in the top left corner...
Also it may seem crazy, but our company does officially support IE 7, and a significant percent still do use it. We deal with many large corporate customers with antiquated IT policies unfortunately.