Forum Moderators: not2easy

Message Too Old, No Replies

Extra padding in Mozilla

         

CompressedAir

11:35 pm on Jan 1, 2004 (gmt 0)

10+ Year Member



Hey people, I've found a ton of useful posts here and have been lurking for a while. :) I have encountered one error that I just can't figure out. It seems when using the code below Mozilla seems to add extra bottom padding to the picture. The page is correctly rendered in both Opera7 and IE6. The picture has 4px padding all the way around in Mozilla, except on the bottom, where it mysteriously adds more padding..

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title>Testing</title>

<style type="text/css">

#picture {
position: relative;
float: left;
margin: 4px;
}
#picture a {
display: block;
border: 3px solid blue;
padding: 4px;
}
#picture img{
border: 1px solid red;
}

</style>

</head>

<body>

<div id="picture">
<a href="#link"><img src="put a picture here!.jpg" alt="alt text here"/></a>
</div>

</body>

</html>

You would need to edit this code to some picture you have to see what I'm talking about. I don't know if it is a Mozilla bug or a some coding mistake.
One thought I had was Mozilla was trying to add an underline to the picture, like a regular text link, resulting in the extra padding, but I'm not really sure...

Any help would be appreciated :)
Thanks

aevea

2:46 am on Jan 2, 2004 (gmt 0)

10+ Year Member



I'm not really sure what's causing the problem, but if you change to a transititional doctype it seems to fix it.

Your also technically supposed to declare a width on a non-replaced floated element (the div):
[w3.org...]
but that doesn't seem to be the cause of your problem.

Adam

iamlost

3:57 am on Jan 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes - Mozilla is generally code compliant and you are forcing an inline element (a is an inline element) to display as a block element.

Mozilla is carrying forward all the inline attributes including line-height. Set "line-height: 0;"


#picture a {
display: block;
border: 3px solid blue;
padding: 4px;
line-height: 0;
}

CompressedAir

3:58 am on Jan 2, 2004 (gmt 0)

10+ Year Member



Aha so it does. Thanks
Well I guess I can just use Transitional doctype..although I'd like it to be xhtml 1.1. Wierd why Mozilla would do that for a xhtml 1.0 strict or xhtml 1.1 doctype.....

CompressedAir

4:00 am on Jan 2, 2004 (gmt 0)

10+ Year Member



oo another post just as I replied.. :)
Thanks iamlost that's it :)
Now I can use 1.1 doctype!