3 replies [Last post]
7724
Offline
Regular
Last seen: 9 years 25 weeks ago
Timezone: GMT+1
Joined: 2005-09-30
Posts: 14
Points: 0

Evening

I have a very simple question that I just can't find the answer to. Take this simple html table with a and

tag:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Title</title>
</head>
<body>
 
<table border="1">
<tr>
<td>
 
<h2>This is the heading</h2>
<p>This is a test</p>
 
</td>
</tr>
</table> 
 
</body>
 
</html>

How can I make it so that the and

tags are closer together (the height). I know I can do it by adding

* {
  margin: 0;
  padding: 0;
}

But I only want it applied within that

(and before anyone asks I do need it in a table! Smile)

Thanks

CupidsToejam
CupidsToejam's picture
Offline
Guru
Florida
Last seen: 7 years 28 weeks ago
Florida
Timezone: GMT-4
Joined: 2008-08-15
Posts: 2637
Points: 1556

td h2, td p {margin: 0;}

td h2, td p {margin: 0;}

wolfcry911
wolfcry911's picture
Offline
Guru
MA, USA
Last seen: 9 years 3 weeks ago
MA, USA
Timezone: GMT-5
Joined: 2004-09-01
Posts: 3224
Points: 237

why do you need a heading

why do you need a heading and paragraph in a table cell? If it's tabular data, are using th?

ljbailey
ljbailey's picture
Offline
Enthusiast
Scotland
Last seen: 12 years 19 weeks ago
Scotland
Joined: 2009-01-10
Posts: 224
Points: 59

Wolfcry is right. If "you do

Wolfcry is right. If "you do need a table" then you need to use table headings.

<table>
<thead>
<tr>
<th>Heading 1</th>
<th>Heading 2</th>
<th>Heading 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1</td>
<td>Row 2</td>
<td>Row 3</td>
</tr>
</tbody>
/*If neccesary you can have <tfoot></tfoot> */
</table>

Liam Bailey is director of Galloway Web Services, a Stranraer web design company, sister of SEO copywriting services company Write About Property.