Build Your Own Website Chapter 6 - Building a table

Hi everyone,

I am working on Build Your Own Website Chapter 6 and for some reason, the first data row of my table is showing gray like the caption row. I have checked my code against the book’s markup several times and can’t find the error. Here is my code:

<!DOCTYPE html>
<html lang="en">
  <head>
<title>Forthcoming diving events and trips with BubbleUnder</title>
<meta charset="utf-8"/>
<link href="style1.css" rel="stylesheet" type="text/css"/>
</head>
  <body>
    <div id="header">
      <div id="sitebranding">
        <h1>BubbleUnder.com</h1>
      </div>
      <div id="tagline">
        <p>Diving club for the south-west UK - let's make
            a splash!</p>
      </div>
    </div>
    <div id="navigation">
    <ul>
  <li><a href="index.html">Home</a></li>
  <li><a href="about.html">About Us</a></li>
  <li><a href="events.html"/>Club Events</a></li>
  <li><a href="contact.html">Contact Us</a></li>
  <li><a href="gallery.html">Image Gallery</a></li>
</div>
  </ul>
    <div id="bodycontent">
      <h2>Forthcoming club events</h2>
      <p>BubbleUnder members love meeting up for dive trips around the country. Below
        are all the dive trips that we currently have planned. For more information
        about any of them, please get in contact with that event's organizer.</p>
    <table>
      <tr>
        <th>Name</th>
        <th>Contact (Home)</th>
        <th>Contact (Work)</th>
        <th>Location</th>
    </tr>
    <tr>
      <td>Jane Bradley</td>
      <td>02380 123123</td>
      <td>02380 577566</td>
      <td>Southampton</td>
</tr>
<tr>
  <td>Fred Bradley</td>
  <td>01273 177166</td>
  <td>01273 916376</td>
  <td>Brighton</td>
</tr>
<tr>
  <td>Lionel Rundel</td>
  <td>01793 641207</td>
  <td>01793 626696</td>
  <td>Swindon</td>
</tr>
</table>
<table class="events" summary="Details of upcoming events and
dive trips">
<caption>Club events - dive trips for the next six months</caption>
<tr>
  <th>Date</th>
  <th>Event Description</th>
  <th>Approximate Cost</th>
  <th>Contact</th>
</tr>
<tbody>
<tr>
  <th>12 July</th>
  <th>Committee meeting, deciding on next year's trips</th>
  <th>N/A</th>
  <th>Bob Dobalina</th>
   </tr>
   <tr>
   <td>19 July</td>
   <td>7-day trip to Hurghada (package deal) - limited spaces</td>
   <td>&pound;260pp (all-inclusive), departing Luton</td>
   <td>Bob Dobalina</td>
   </tr>
   <tr>
   <td>5 August</td>
   <td>Ocean &amp; Sports Diver Theory Course</td>
   <td>Call for details</td>
   <td>Jeff Edgely</td>
 </tr>
 <tr>
  <td>12 August</td>
  <td>Murder Mystery Weekend, Cotswolds (no diving!)</td>
  <td>&pound;65pp (accommodation included)</td>
  <td>Jill Smith</td>
</tr>
</tbody>
</table>
</div> 
  </body>
</html>

Any help would be much appreciated. Thanks!

Hi @therealramona. We’ll need to see the CSS which goes with that, to know what’s going wrong with the styling.

To post code here, you can either highlight the code and use the </> button on the edit box to format it, or type three backticks

```

on a line above your code, and three on a line below it. I find this method easier. (The backtick is left of the 1 on my UK keyboard; unfortunately, some European keyboards don’t have that key at all.)

Edit: It appears that copying and pasting my three above doesn’t work, because the formatting is inserting spaces. They need to be typed direct.

Thanks! Here is the CSS:

body {
font-family: Verdana, Helvetica, Arial, sans-serif;
	background-color: #e2edff;
	line-height: 125%;
	padding: 0;
	margin: 0;
}
h1 {
	font-family: "Trebuchet-MS", Arial, Helvetica, sans-serif;
	font-size: x-large;
}
li {
	font-size: small;
	list-style-type: none;
}
h2 {
	color: blue;
	font-size: medium;
	font-weight: normal;
}
p {
	font-size: small;
	color: navy;
}
#tagline p {
	font-style: italic;
	font-family: Georgia, Times, serif;
	background-color: #bed8f3; 
	border-top: 3px solid #7da5d8;
	border-bottom: 3px solid #7da5d8;
	padding-top: .2em;
	padding-bottom: .2em;
	padding-left: .8em;
	margin: 0;
}
em {
	text-transform: uppercase;
}
h1, h2, h3 {
	font-family: "Trebuchet-MS", Helvetica, Arial, sans-serif;
}

	h1 {
		font-size: x-large;
		background-color: navy;
		color: white;
		padding-top: 2em;
		padding-bottom: .2em;
		padding-left: .4em;
		margin: 0;
		background: navy url(header-bg.jpg) repeat-y right;
	}
	
	h2 {
		color: navy;
		font-size: 130%;
		font-weight: normal;
		padding-top: 15px;
	}
a {
	font-weight: bold;
}
a link {
	color: black;
}
a visited {
	color: navy;
}
a hover {
	text-decoration: none;
	color: white;
	background-color: navy;
}
a active {
	color: aqua;
	background-color: navy;
}
.fun {
	color: #339999;
	font-family: Georgia, Times, serif;
	letter-spacing: 0.05em;
}
#navigation {
	width: 180px;
	background-color: #7da5d8;
}
#header {
	border-top: 3px solid #7da5d8;
}

#navigation, #bodycontent, #header {
	position: absolute;
}
#navigation, #bodycontent {
	top: 6.54em;
}
#bodycontent {
	left: 200px;
}
#header {
	width: 100%;
}
.feature{
	float: right;
	margin: 10px;
}

.galleryphoto p {
  font-size: 65%;
  font-weight: bold;
  margin-top: 0;
  width: 430px;
  line-height: 1.4em;
}

.photocredit {
  font-weight: normal;
  color: gray;
}
  .galleryphoto img {
	border: 15px solid white;
}
.galleryphoto {
	padding-bottom: 20px;
	border-bottom: 1px solid navy;
	margin-bottom: 10px;
}
#navigation {
	width: 180px;
	height: 484px;
	background: #7da5d8 url(nav-bg.jpg) no-repeat;
}
td {
	border: 1px solid black;
}
table {
	border-collapse: collapse;
	border: 1px solid black;
}
th {
	text-align: left;
	background: gray;
	color: white;
	padding: 0.2em;
}
table.events {
	border-collapse: collapse;
}
table.events th, table.events td; {
	padding: 4px;
	border: 1px solid #000066;
} 
table.events th {
	font-size: x-small;
	text-align: left;
	background: #241374 url (header-bg.jpg);
	color: #ffffff;
	padding-top: 0;
	padding-bottom: 0;
	padding-left: 2px;
	padding-right: 2px;
}
table.events td {
	font-size: small;
	background: #e2edff url(td.jpg) repeat-x top;
}
table.events caption {
	color: #000066;
	font-size: small;
	text-align: left;
	padding-bottom: 5px;
	font-weight: bold;
}

Hi,

The first row of your second table (inside tbody) is using th tags instead of td tags.

<tr>
		<th>12 July</th>
		<th>Committee meeting, deciding on next year's trips</th>
		<th>N/A</th>
		<th>Bob Dobalina</th>
</tr>

It should be:

<tr>
		<td>12 July</td>
		<td>Committee meeting, deciding on next year's trips</td>
		<td>N/A</td>
		<td>Bob Dobalina</td>
</tr>

Fixed! Thanks so much!

So it wasn’t a CSS problem at all. I should have looked more closely…

It was easier to spot with the css in place but yes it was solvable without CSS :smile:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.