Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 780597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:05:57+00:00 2026-05-14T20:05:57+00:00

Can somebody please explain this IE7 bug to me? It occurs in Standards and

  • 0

Can somebody please explain this IE7 bug to me? It occurs in Standards and Quirks mode rendering, it does not occur in Firefox, Chrome or IE8 (though switching the rendering engine via IE8 developer tools will provoke it). Here’s the HTML to reproduce the behavior:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
  "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <title>Test</title>
    <style type="text/css">
        /* h1      { margin: 0px; } */
        ul      { padding: 0; margin: 0; list-style-type: none; }
        ul li   { float: left; width: 140px; padding: 3px; }
        div     { clear: left; padding: 3px; } 
        div, li { background-color: OrangeRed; }
        /* ul      { border: 1px solid blue; } */
    </style>
</head>
<body>
    <h1>Heading 1</h1>
    <ul>
      <li>bla 1</li><li>bla 2</li><li>bla 3</li>
    </ul>
    <div>yada</div>
</body>
</html>
  • This renders a floated <ul> above a <div> (supposed to be a tabbed user interface).
  • There’s an unexplained gap between the <div> and the <ul>.
  • Now do one of the following:
    1. Uncomment the CSS rule for <h1>. The gap disappears and the list is rendered tight to the <div>, but also very close to the <h1>.
    2. Alternatively, uncomment the CSS rule for <ul>. Now a narrow blue border is rendered above the <ul>, but the gap disappears.

My questions:

  1. How can the <h1> margin (I suppose any block level element with a defined margin will do) affect the space below the list?
  2. Can I prevent this from happening without having to set header margins to 0 or messing with the <ul> borders (setting border-width: 0; does not work BTW)?

I suppose it is connected to the <ul> itself having no height because it has only floated children. Maybe someone with more insight into IE7 peculiarities than I have can explain what the rendering engine is doing here. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T20:05:58+00:00Added an answer on May 14, 2026 at 8:05 pm

    I’ve come up with a solution that is what seems like a good compromise. It’s based on the fact that setting a border on the <ul> solves the problem, while the margin-bottom of the preceding-sibling block-level element obviously causes it.

    So setting a border-top: 1px solid transparent; on the <ul> displaces it by merely one pixel, which is okay with me. As BalusC rightly points out in the comments, setting margin-top: -1px; would counteract the displacement.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
      "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
        <title>Test</title>
        <style type="text/css">
            ul      { padding: 0; margin: 0; border-top: 1px solid transparent; list-style-type: none; }
            ul li   { float: left; width: 140px; background-color: red; }
            div     { clear: left; background-color: red; } 
        </style>
    </head>
    <body>
        <h1>Heading 1</h1>
        <ul>
          <li>bla 1</li><li>bla 2</li><li>bla 3</li>
        </ul>
        <div>yada</div>
    </body>
    </html>
    

    I admit that this is a bit of hackery, too; it requires remembering what the bogus border is for, which is not much better than the usual CSS tricks (but a little).


    Previous version of the answer: I’ve fixed it like this for now (seems it works across browsers and does not require CSS hackery)

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
      "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
        <title>Test</title>
        <style type="text/css">
            div.t ul    { padding: 0; margin: 0; list-style-type: none; }
            div.t ul li { float: left; width: 140px; background-color: red; }
            div.c       { background-color: red;  } 
        </style>
    </head>
    <body>
        <h1>Heading 1</h1>
        <div class="t">
          <ul>
            <li>bla 1</li><li>bla 2</li><li>bla 3</li>
          </ul>
          <br style="clear: left;">
        </div>
        <div class="c">yada</div>
    </body>
    </html>
    

    I don’t like this solution very much because the of the extra elements it requires. But I dislike dirty CSS tricks even more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got: error a1 was not declared in this scope Can somebody please explain
Can somebody please explain what does this warning mean: undefined reference to 'WinMain@16' ?
can somebody please explain how does 0 influence mmap in python in this case:
I do not understand how this code is compiling. Can somebody please explain what
Can somebody please explain to me the meaning of this line of code? val
can somebody please explain what this program is doing? .= torg + 1000 main:
can somebody please explain is it possible to convert this snippet of the code
can somebody please explain my mistake, I have this class: class Account { private:
Can somebody please explain how this works in jQuery. I tried to find some
I do not know where my head is today, can somebody please explain to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.