tags:

views:

158

answers:

5

I've tried to set the margin and border to 0,but still not working.

<style type="text/css">
img {margin:0;}
</style>
<body>

<img src="/static/btnNext.gif" border="0" />
<img src="/static/btnSave.gif" border="0" />

How to make two images stay close to each other?

+2  A: 
<style type="text/css">
img {margin:0; float: left;}
</style>
o.k.w
A: 

You forgot the padding.

mouviciel
This is a comment, not an answer.
Mike
+8  A: 

You can eliminate the css for the image and put the image tags on the same line with no space.

<img src="/static/btnNext.gif" border="0" /><img src="/static/btnSave.gif" border="0" />
jeerose
+1 this is the correct answer in this case as it produces no side-effects (what `float:left` and `display:block` do).
Török Gábor
@jeerose +1, thanks! @Mak: on FF 3.6 and Safari using DOCTYPE your example works perfectly and new lines between images are IGNORED! An exception (as usual) is obvioulsy IE7 (did not try IE8) that show this strange behaviour, and the only workaround seem to be the one suggested by jeerose.
Marco Demajo
A: 

this css should stick the images close to eachother without any space, linebreaks or borders between the images...

<style type="text/css">
img {margin:0px; padding: 0px; float: left;border:0px}
</style>
QuBaR
A: 

I would suggest to put each image in a individual div having style float:left. These 2 divs should be enclosed within a parent div which itself is float: left like,

<div style="float:left">
<div style="float:left">
<img src="/static/btnNext.gif" border="0" />
</div>
<div style="float:left">
<img src="/static/btnSave.gif" border="0" />
</div>
</div>
Justin