IE cannot put padding on IMGs?

D

delerious

I'm trying to add some simple padding to an IMG by using a padding-right
style, but it doesn't work in IE. Works fine in Mozilla and Opera, though.

Here's a link to a page which displays this IE problem:

http://home.comcast.net/~delerious1/index12.html

I do know that I can solve the problem in IE by changing padding-right to
margin-right, but then the links cannot be clicked when the mouse is over that
margin area. So I would really like to get the padding working in IE. Any
ideas?
 
E

Evertjan.

wrote on 21 dec 2003 in comp.infosystems.www.authoring.stylesheets:
I'm trying to add some simple padding to an IMG by using a
padding-right style, but it doesn't work in IE. Works fine in Mozilla
and Opera, though.

Padding is IMHO putting a spacing between a container and its contents.
But an img is NOT a container, so IE is right not to construct that.
It is like padding a string of letters instead of its container.

+++ You cannot padd(?) something around itself,
padding is an inside job. +++

If you want padding AROUND an image, that is called a margin.


<span style="padding:3px;"><img src=".."></span>

is about the same as

<img style="margin:3px;" src="..">

so never use the same class for img and containers, if you want to use
things ike padding in it.
 
A

Anne van Kesteren

Evertjan. said:
Padding is IMHO putting a spacing between a container and its contents.
But an img is NOT a container, so IE is right not to construct that.
It is like padding a string of letters instead of its container.

Padding is spacing between the border and the contents. Margin is
spacing between the total width (width+padding+border) of the element
and the container.
+++ You cannot padd(?) something around itself,
padding is an inside job. +++

That is incorrect. Especially for images the W3C box model makes sense.
If you want padding AROUND an image, that is called a margin.

Again, incorrect.
so never use the same class for img and containers, if you want to use
things ike padding in it.

:?
 
S

SwissCheese

I'm trying to add some simple padding to an IMG by using a padding-right
style, but it doesn't work in IE. Works fine in Mozilla and Opera, though.

Here's a link to a page which displays this IE problem:

http://home.comcast.net/~delerious1/index12.html

I do know that I can solve the problem in IE by changing padding-right to
margin-right, but then the links cannot be clicked when the mouse is over that
margin area. So I would really like to get the padding working in IE. Any
ideas?

The problem lies in trying to make the A element display as BLOCK while
including an image as part of the link. See my previous examples from your
other questions. There are better answers i'm sure but I get identicle
output in both IE6 and Mozilla, Opera is another story...
 
D

delerious

The problem lies in trying to make the A element display as BLOCK while
including an image as part of the link. See my previous examples from your
other questions. There are better answers i'm sure but I get identicle
output in both IE6 and Mozilla, Opera is another story...

Thanks for the replies, SwissCheese.
 
E

Evertjan.

Anne van Kesteren wrote on 21 dec 2003 in
comp.infosystems.www.authoring.stylesheets:
Padding is spacing between the border and the contents. Margin is
spacing between the total width (width+padding+border) of the element
and the container.


That is incorrect. Especially for images the W3C box model makes
sense.


Again, incorrect.

Beste Anne,

I put to you that saying that something is incorrect or makes sense will
give you a moral obligation to tell us why you think so.

I state that a IMG has no content, because it is the content itself.
IMG is no container, it cannot have a inside child, the displayed image
is just a property [or perhaps value] of the IMG.

That's why the idea of padding makes no sense. IE acts on that notion.

Border is something around the img, that can have a size of zero or
bigger and a color or other graffics, and is inside a possible margin
area. Border does not define a container.

Padding is like putting a margin around the children of an object,
remembering that the childs own margin is inside that again.

btw: If the IMG is inline [default] or box [is that possible?] should
have nothing to do with that.

Als je het er niet mee eens bent, leg dan aljeblieft uit waarom.
 
T

Toby A Inkster

Evertjan. said:
I state that a IMG has no content, because it is the content itself.
IMG is no container, it cannot have a inside child, the displayed image
is just a property [or perhaps value] of the IMG.

That's why the idea of padding makes no sense.

It does make sense -- you just have to image that the picture itself is an
anonymous child element of said:
IE acts on that notion.

IE acts wrong then.

If I write:

<img src="foobar" alt="Foo Bar" style="margin: 1em; padding: 1em; border:
thin solid black;">

the correct rendition is to draw the picture itself (anonymous child of
<img>), surrounded by 1em of blank space, surrounded by a thin solid black
border, surrounded by another 1em of blank space.
 
B

Brian

Evertjan. said:
I state that a IMG has no content, because it is the content itself.
IMG is no container, it cannot have a inside child, the displayed image
is just a property [or perhaps value] of the IMG.

That's why the idea of padding makes no sense.

I'm sorry, but padding for an img element does make sense, at least to
me. I fail to see why that element should be accepted from the box model.
IE acts on that notion.

I didn't know that. But MSIE fails to implement the specs, is that
evidence of anything other than the failures of MS?
Border is something around the img, that can have a size of zero or
bigger and a color or other graffics, and is inside a possible margin
area.

And if the padding is 0, the border will be snug with the image data;
if the padding is > 0, there will be space between the image and its
border. Is there some reason why you want there to be no option here?
btw: If the IMG is inline [default] or box [is that possible?]

Do you mean block? display: block can be applied to an img element.
 
A

Anne van Kesteren

Toby said:
IE acts wrong then.

AFAIK, it works in IE6. Standard compliant mode on.

Example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<style type="text/css">
body{
margin:2em;
}
img{
padding:1em;
border:2em solid red;
}
</style>
<img src="" alt="padding + border test image" height="20" width="20">
 
D

delerious

This solution works in IE 5.5 and 6, but not IE 5.0.

Looks like I am going to have to use the really ugly solution of:

<a href="..."><img src="..."><span>&nbsp;</span>link</a>

and in the css:

span {
font-size: 0.7
}
 
S

Steve Pugh

Looks like I am going to have to use the really ugly solution of:

<a href="..."><img src="..."><span>&nbsp;</span>link</a>

and in the css:

span {
font-size: 0.7
}

0.7 what?

And is it not possible to edit the image to inclue the extra space you
want? Sometimes the simplest option is the best.

Steve
 
D

delerious

0.7 what?

Oh, I forgot to put in the "em" :)

And is it not possible to edit the image to inclue the extra space you
want? Sometimes the simplest option is the best.

I guess I could add in some transparent space... but then that extra space
wouldn't scale if the text size changed.
 
S

Steve Pugh

I guess I could add in some transparent space... but then that extra space
wouldn't scale if the text size changed.

That is true. I was going by the example you posted in the first
message, <URL: http://home.comcast.net/~delerious1/index12.html> which
used padding-right: 10px;
And, of course, the images themselves won't resize if the text size
changes unless you specify their sizes in ems which is not a good idea
unless the images are very simple.

Steve
 
D

delerious

Looks like I am going to have to use the really ugly solution of:

<a href="..."><img src="..."><span>&nbsp;</span>link</a>

and in the css:

span {
font-size: 0.7
}

I have a better solution now involving conditional comments in IE:

<a href="..."><span style="padding-right: 0.3em"><img src="..."></span>
<!--[if IE 5.0]><span>&nbsp;</span><![endif]-->link</a>

Of course I can't verify that this works right now as I'm encountering that
multiple IE installation version number problem, but I'm pretty sure it will
work. (famous last words, I know!)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top