2 Replies - 261 Views - Last Post: 08 September 2011 - 03:46 PM

#1 Kyoku  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 06-September 11

PHP generated table with image - need to get rid of bottom spacing

Posted 08 September 2011 - 02:14 PM

The problem I have is this :

Posted Image

I can't figure out where it's coming from, and the tile is a 100x100 jpg in case you were wondering ...


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Test</title>

	<style type="text/css" media="screen">
body {
	//margin:0px;
	background-color:#333333;
	color:#FFFFFF;
	//padding:0px;
}

td
{
padding:0px;
}

table
{
padding:0px;
border-collapse:collapse;
//border-spacing:0px;
}

table,th,td
{
border: 1px solid yellow;
}

	</style>
</head>

<body>

TEST 2

<?php
	echo "<table><tr>";
	$images=array( // list of files - add as needed
  	"tile001.jpg" );

  echo "<td><img src='$images[0]'></td>";

	echo '</tr></table>';
?>

</body>
</html>



Many thanks !

Is This A Good Question/Topic? 0
  • +

Replies To: PHP generated table with image - need to get rid of bottom spacing

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4307
  • View blog
  • Posts: 12,088
  • Joined: 18-April 07

Re: PHP generated table with image - need to get rid of bottom spacing

Posted 08 September 2011 - 02:39 PM

First of all, you should be using /* and */ to comment out lines of CSS.

Secondly, the problem you are showing is due to the fact you are using strict as your doctype. In strict mode images were considered inline elements so space was reserved for lower descending characters. Since images don't have these characters (like the drop in a "p" or "q") this space was never used.

One way to fix this is to tell images not to use this extra space...

img {
   vertical-align: top;
}



I hope this clarified the situation. :)

This post has been edited by Martyr2: 08 September 2011 - 02:40 PM

Was This Post Helpful? 1
  • +
  • -

#3 Kyoku  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 06-September 11

Re: PHP generated table with image - need to get rid of bottom spacing

Posted 08 September 2011 - 03:46 PM

Thanks! That solved it :bananaman:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1