# HTML:  Putting images edge-to-edge

**URL:** https://boards.straightdope.com/t/html-putting-images-edge-to-edge/331436
**Category:** Factual Questions
**Created:** [November 17, 2005, 3:01am UTC](https://boards.straightdope.com/t/html-putting-images-edge-to-edge/331436 "2005-11-17T03:01:52Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![CookingWithGas](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/cookingwithgas/32/485_2.png) [@CookingWithGas](https://boards.straightdope.com/u/CookingWithGas)
#### Post date: [November 17, 2005, 3:01am UTC](https://boards.straightdope.com/t/html-putting-images-edge-to-edge/331436/1 "2005-11-17T03:01:52Z")

</div>

I have several images I am trying to “glue” together to form what will appear to be a single image. But the page shows a gap between all the images, instead of putting them edge-to-edge seamlessly.

Is there a way to do this that is consistent with most major browsers?

---

<div class="post-metadata">

### Author: ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)
#### Post date: [November 17, 2005, 3:08am UTC](https://boards.straightdope.com/t/html-putting-images-edge-to-edge/331436/2 "2005-11-17T03:08:31Z")

</div>

Make a single image.

---

<div class="post-metadata">

### Author: ![Omphaloskeptic](https://avatars.discourse-cdn.com/v4/letter/o/bcef8e/32.png) [@Omphaloskeptic](https://boards.straightdope.com/u/Omphaloskeptic)
#### Post date: [November 17, 2005, 3:39am UTC](https://boards.straightdope.com/t/html-putting-images-edge-to-edge/331436/3 "2005-11-17T03:39:38Z")

</div>

What does your HTML look like, and what browsers are you using? This simple code

```auto

<html><head></head><body><img src="1.jpg"><img src="2.jpg"></body></html>

```

gave no spaces between the images for me (recent IE and Mozilla).

Make sure you don’t include any whitespace (including CR/LF!) between your IMG tags. For example, this:

```auto

<html><head></head><body><img src="1.jpg">
<img src="2.jpg"></body></html>

```

will give a space between the two images (they’re thought of as inline with text, separated by a space).

Alternately, you should be able to insert the images into a table, and set all borders and margins to zero; this will let you format the HTML more easily:

```auto

<html><head>
<style>
table { border-collapse: collapse; }
td { border: 0px; padding: 0px; }
</style>
</head><body>
<table><tr>
<td><img src="pic1.jpg"></td>
<td><img src="pic1.jpg"></td>
</tr></table>
</body></html>

```

---

<div class="post-metadata">

### Author: ![ZipperJJ](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/zipperjj/32/211_2.png) [@ZipperJJ](https://boards.straightdope.com/u/ZipperJJ)
#### Post date: [November 17, 2005, 4:53am UTC](https://boards.straightdope.com/t/html-putting-images-edge-to-edge/331436/4 "2005-11-17T04:53:54Z")

</div>

If you go with Omphaloskeptic’s table idea (which is what I would have suggested) be sure to format the table cells like s/he shows - the \<td\> and image tags on one line.

IE, and I think Firefox, will put space around images if they’re not on one line with the cell tags. Not sure why, but they do.

---

<div class="post-metadata">

### Author: ![Harmonious\_Discord](https://avatars.discourse-cdn.com/v4/letter/h/74df32/32.png) [@Harmonious\_Discord](https://boards.straightdope.com/u/Harmonious_Discord)
#### Post date: [November 17, 2005, 5:28am UTC](https://boards.straightdope.com/t/html-putting-images-edge-to-edge/331436/5 "2005-11-17T05:28:01Z")

</div>

You can also make one picture in a jpeg format that loads the pictures in blocks, and each block is in full resolution. Another jpeg format fills in the details over time. You see a blury image that resolves into a high definition image over time. It’s not the question you asked, but a possible solution for loading a graphics image in an internet friendly manner. You don’t have to worry about multiple files or locational errors leaving spaces between images used for one larger image.

---

<div class="post-metadata">

### Author: ![Oswald\_Bastable](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/oswald_bastable/32/214_2.png) [@Oswald\_Bastable](https://boards.straightdope.com/u/Oswald_Bastable)
#### Post date: [November 17, 2005, 12:43pm UTC](https://boards.straightdope.com/t/html-putting-images-edge-to-edge/331436/6 "2005-11-17T12:43:46Z")

</div>

> [@ZipperJJ](#):
>
> If you go with Omphaloskeptic’s table idea (which is what I would have suggested) be sure to format the table cells like s/he shows - the \<td\> and image tags on one line.
> 
> IE, and I think Firefox, will put space around images if they’re not on one line with the cell tags. Not sure why, but they do.

I you use PhotoShop you could also use the slice tool and Save for web to generate the image slices and code. Other image manipulation software may also have a similar feature.

OB

---

<div class="post-metadata">

### Author: ![CookingWithGas](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/cookingwithgas/32/485_2.png) [@CookingWithGas](https://boards.straightdope.com/u/CookingWithGas)
#### Post date: [November 17, 2005, 3:54pm UTC](https://boards.straightdope.com/t/html-putting-images-edge-to-edge/331436/7 "2005-11-17T15:54:00Z")

</div>

> [@Omphaloskeptic](#):
>
> Make sure you don’t include any whitespace (including CR/LF!) between your IMG tags.

This appears to be the issue. I have line breaks to make the code more readable. I forgot about the inserted space.

The reason I am using multiple images is that some of the images have anchor tags to link to other pages. I guess I could do that with a map instead but I’m too lazy to learn how to do that. 😉

---

<div class="post-metadata">

### Author: ![simster](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/simster/32/1047_2.png) [@simster](https://boards.straightdope.com/u/simster)
#### Post date: [November 17, 2005, 7:48pm UTC](https://boards.straightdope.com/t/html-putting-images-edge-to-edge/331436/8 "2005-11-17T19:48:38Z")

</div>

If you do a table… be sure to set the cellpadding, cellspacing and border attributes to 0 (zero)…

Also, there are hspace and vspace attributes for the image tags that control some amount of whitespace around the images… set them to 0 as well.

and of course, the stylesheet idea from above would also do the trick.
