views:

2934

answers:

4

I'm working on a page has an ol with nested p's, div's, and li's. Internet Explorer 6 and 7 both render the numbers for the ol tag after the p element at the end (at the very, very bottom of the li tag) rather than at the top of the outermost li as expected. I'm working on a PowerPC Mac and can't do any testing. Is there some simple CSS hack to make this render the same as it does in Firefox?

You can view the live page here. I know, I'm working on positioning the sidebar. Ignore that for now.

Markup is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" type="text/css" href="css/global.css" />
        <link rel="stylesheet" type="text/css" href="css/whats_included.css" />
        <script type="text/javascript" src="script/compliant_target_blank.js"></script>
        <!--[if lte IE 5]>
            <script type="text/javascript" src="script/ie_5_unsupported_warning.js"></script>
        <![endif]-->
        <!--[if gt IE 5]>
            <link rel="stylesheet" type="text/css" href="css/ie_hacks/global.css" />
        <![endif]-->
        <title>
            The Daily Plan-It, LLC - Home of the Tax MiniMiser
        </title>
    </head>
    <body>
        <?php include("includes/nav_bar.php") ?>

        <div id="content">
            <img src="images/title.png" alt="Tax MiniMiser Financial Tracking System" />
            <div id="bordered_wrapper">
                <h1>Here's What You Get With The Tax MiniMiser!</h1>
                <h2>24 Envelopes, 7-hole punched to fit one-at-a-time in your binder</h2>
                <ol>
                    <li class="main_item">
                        Business Income &amp; Expense Record
                        <div class="preview_image">
                            <a href="previews/large/bier/front.html" rel="external">
                                <img src="images/small_previews/large/bier_preview.jpg" alt="" /><br/>
                                Click to Preview!
                            </a>
                        </div>
                        <div class="details">
                            <ul>
                                <li>12 receipt envelopes with all the income &amp; expense columns you need to transform your planner or binder into a daily tax journal!</li>
                                <li>Store daily receipts in the convenient pocket envelopes.</li>
                            </ul>
                        </div>
                        <p>To get a free copy of the &quot;20 Column Heading Guidelines&quot;, <a href="files/downloads/20_column_heading_guidelines.pdf">click here</a> or call our Fax-on-Demand line at 888-829-8237.</p>
                    </li>
                    <li class="main_item">
                        Vehicle Mileage &amp; Expense Record
                        <div class="preview_image">
                            <a href="previews/large/vme/front.html" rel="external">
                                <img src="images/small_previews/large/mileage_preview.jpg" alt=""/><br/>
                                Click to Preview!
                            </a>
                        </div>
                        <div class="details">
                            <ul>
                                <li>12 receipt envelopes to track your daily mileage and vehicle expenses. Keep one envelope in each vehicle used for your business(es).</li>
                                <li>Store daily receipts in the convenient pocket envelopes.</li>
                            </ul>
                        </div>
                        <p>To get a free copy of the &quot;Instructions for Vehicle Mileage &amp; Expense Record&quot;, <a href="files/downloads/vehicle_record_instructions.pdf">click here</a> or call our Fax-on-Demand line at 888-829-8237.</p>
                    </li>
                    <li class="main_item">
                        Annual Business Summary of Income and Expense
                        <div class="preview_image">
                            <a href="previews/large/cover/inside.html" rel="external">
                                <img src="images/small_previews/large/cover_inside_preview.jpg" alt="" /><br/>
                                Click to Preview!
                            </a>
                        </div>
                        <div class="details">
                            <ul>
                                <li>Enter the subtotals from all the envelopes throughout the year. Then you and your tax pro can figure out profitability and taxes to maximize your deductions and legally minimize your taxes.</li>
                            </ul>
                        </div>
                    </li>
                </ol>
                <p class="end">To see previews of the small (6&quot; x 8&frac12;&quot;) Tax MiniMisers, visit their respective pages <a href="products.php">here.</a></p>
            </div>
        </div>

        <?php include("includes/footer.php") ?>
    </body>
</html>

And the CSS:

#content {
    background-color: white;
}

#bordered_wrapper {
    margin-left: 26px;
    background: top left no-repeat url(../images/borders/yellow-box-top.gif);
}

#bordered_wrapper h1, #bordered_wrapper h2 {
    margin-left: 20px;
}

#bordered_wrapper h1 {
    padding-top: 15px;
    margin-bottom: 0;
}

#bordered_wrapper h2 {
    margin-top: 0;
    font-size: 1.3em;
}

ol {
    font-size: 1.1em;
}

ul {
    list-style-type: disc;
}

li.main_item {
    width: 700px;
    clear: right;
}

li p {
    clear: both;
    margin-bottom: 20px;
}

.preview_image {
    width: 200px;
    float: right;
    text-align: center;
    margin-bottom: 10px;
}

.preview_image a {
    text-decoration: none;
}

.preview_image img {
    border-style: none;
}

.end {
    clear: right;
    padding-bottom: 25px;
    padding-left: 20px;
    background: bottom left no-repeat url(../images/borders/yellow-box-bottom.gif);
}
A: 

I just tested your example html in firefox 3/webkit nightly/internet explorer 7 and all of them rendered exactly the same with the number at the top where it should be.

The problem is probably in your CSS, can you show us the actual page that is broken?

I can see the error on IE7 on Vista.
Sam Hasler
Answer not based on the live page.
Dustman
A: 

Same here, tested with IE6 on WinXP Pro SP3, it shows correctly. You should provide a snippet reproducing the problem, or a live Web page. Perhaps the environment counts, or the existing CSS, etc.

PhiLho
Answer not based on the live page.
Dustman
The live page wasn't there in the initial question, when I answered. Check the history! My answer was useful since original poster added relevant information.
PhiLho
Well that would be a useful _comment_, but it isn't a useful _answer_.
Dustman
OK, I understand the nuance, although I often complete the answer after getting more info.But I will take this in account in the future...
PhiLho
+5  A: 

Congratulations, you are the victim of IE's hasLayout property.

Short version: You've got it easy this time. Changes these rules:

...

ol {
    font-size: 1.1em;
}

...

li.main_item {
    width: 700px;
    clear: right;
}

...

To this:

...

ol {
    font-size: 1.1em;
    width: 700px;
}

...

li.main_item {
    clear: right;
}

...

And it's all good.

Longer version: When you apply certain CSS rules to certain elements, IE 5.5+ gives those elements a property called "hasLayout" that changes how that element is rendered. Since hasLayout was a read-only property with no apparent purpose, it took quite a while before web designers caught on to the issue. Older sites (even Quirksmode.org!) still has pages that suggest twiddling padding, margins, or even using Javascript to fix these issues. If you can at all help it, don't do these things. Instead, see if you can find out what element is incorrectly being given hasLayout, and change the offending CSS so that the element no longer gets hasLayout. If that totally borks your page, use conditional comments to fix it just for IE. Here are some CSS rules that add "hasLayout" to an element that doesn't already have it:

  • position: absolute
  • float: left|right
  • display: inline-block
  • height: any value other than 'auto'
  • zoom: any value other than 'normal' (MS proprietary)
  • writing-mode: tb-rl (MS proprietary)

As of IE7, overflow became a trigger for hasLayout.

  • overflow: hidden|scroll|auto

Longest version: read the following articles.

  1. Here's all the neat things Microsoft would like you do by triggering "hasLayout".
  2. Here's the clean-language version of what web designers thought about hasLayout when they found out what was going on. Some of the same content, but includes CSS hacks and stuff.
Dustman
A: 

Actually, I ran into this bug as well. With my page it only happened after changing the numbering using javascript. The only somewhat real solution available is using:

vertical-align: top;

I honestly have no idea why IE7 is doing, however there is an easy way to fix it.

Jesse Dijkstra