views:

550

answers:

1

I'm sure someone has noticed this before but I can't seem to find a solution. In IE7 before and after form tags IE inserts line breaks. This is no good! Sample code below... Solutions? Ideas?

  <html>
    <body>
        <div id="pageContent" style="border:1px solid black; background-color:orange;">
        <form> 
        content bad <!-- notice spaces before and after form tags --> 
        </form> 
        </div>
        <div id="pageContent2" style="border:1px solid black; background-color:orange;">
        content good <!-- no spacing -->
        </div>
    </body>
    </html>
+7  A: 

Start with a valid doctype declaration above your <html> tag. Omitting this causes the browser to use quirks mode instead of standards mode.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;

If that doesn't solve it, add a css rule to remove all margin and padding from form elements:

form { margin: 0; padding: 0; }
John Sheehan
Agreed, just set margin-top and margin-bottom for the form tag to 0.
Karl
Margin 0 does the trick! Thanks!
payling