tags:

views:

27

answers:

2

i using doctype:

http://www.w3.org/TR/html4/strict.dtd

full code:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
<HTML>
<BODY>
<div style="border:1px solid red;background-color:blue;"><img src="http://www.google.com/intl/en_ALL/images/srpr/logo1w.png"&gt;&lt;/div&gt;
</BODY>
</HTML>

you can check it out here

in chrome or firefox,why has a padding on bottom?

how to fix it?

(if I remove doctype, or in IE ,it's be okey)

alt text

+6  A: 

Set the image to display: block (preview), and it will no longer generate a line box. (Also, be aware that jsFiddle is annoying for doctype switching since it wraps your HTML.)

Read about the inline formatting model and almost standards mode.

jleedev
A: 

EDIT: jleedev has the right answer. not deleting this because it is often the answer to this sort of issue

Different browsers have different "default" styles for elements. One popular technique is to use a "CSS Reset" stylesheet, that sets everything to neutral values for you, so that you can get consistent results across browsers.

Matt Briggs
That has no effect in this case. CSS 2.1 recommends that image should have display:inline by default anyway — note that the reset stylesheet is more concerned with fonts, colors, margins and padding, and does not change any display property.
jleedev
@jleedev: you are totally right. I didn't take the time to really look at what he was talking about, usually random margins and padding on different browsers mean the user agent stylesheets are different. voting you up
Matt Briggs