tags:

views:

195

answers:

6

The following code should display table with borders around cells, but it doesn’t. Any idea why?

<head>
<meta http-equiv=“content-type” content=“text/html; charset=ISO-8859-1” />
   <style type=“text/css”>
    td, th {border: 1px solid black;}
   </style>
<title>Testing Tony’s Travels</title>
</head>
<body>
 <table>
  <tr>
     <th>City</th>
     <th>Date</th>
     <th>Temperature</th>
     <th>Altitude</th>
     <th>Population</th>
     <th>Diner Rating</th>
  </tr>
  <tr>
     <td>Walla Walla, WA</td>
     <td>June 15th</td>
     <td>75</td>
     <td>1,204 ft</td>
     <td>29,686</td>
     <td>4/5</td>
  </tr>
  <tr>
     <td>Magic City, ID</td>
     <td>June 25th</td>
     <td>74</td>
     <td>5,312 ft</td>
     <td>50</td>
     <td>3/5</td>
  </tr>
 </table>
</body>
</html>
+1  A: 

Is this the whole document?

If it is, you might want to add a document type and html tags.

jeroen
I've ommited DOCTYPE and messed up opening HTML tag when pasting code here. Code is from copied from http://headfirstlabs.com/books/hfhtml/code/HFHTML_ch13.zip
SourceC
+2  A: 

You're missing an opening <html> tag; is that just an accident from copy/pasting your code here? Also, fix the quotes in the meta and style tags:

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
and
<style type="text/css">

Adding a proper DOCTYPE is probably a good idea too, although you'll get borders to display from just making the above fixes.

For future reference, running your HTML through the W3C Validator or HTML Tidy can instantly identify issues like this.

Donut
I've ommited DOCTYPE and messed up opening HTML tag when pasting code here. Code is from copied from http://headfirstlabs.com/books/hfhtml/code/HFHTML_ch13.zip
SourceC
+2  A: 

Should probably use http://doctype.com/

it works for me if you use the html tag around your text and replace your quotes with actual " or ' (you are using ” which isn't the same. Look closely ” != ")

Gordon Tucker
I've replaced quotes and it works now - yay. Thank you all
SourceC
+1  A: 

It shows borders for me in IE6, IE7, IE8, FF3, and Chrome 3, but the borders are around each cell individually.

If you want the borders to appear connected, just add this in your style tag:

table { border-collapse: collapse; }

Noah Heldman
I've meant to say that there are no borders around individual cells
SourceC
+1  A: 

your double quotes aren't proper double quotes. try

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<head>
   <style type="text/css">
    td, th {border: 1px solid black;}
   </style>
<title>Testing Tony’s Travels</title>
</head>
<body>
 <table>
  <tr>
     <th>City</th>
     <th>Date</th>
     <th>Temperature</th>
     <th>Altitude</th>
     <th>Population</th>
     <th>Diner Rating</th>
  </tr>
  <tr>
     <td>Walla Walla, WA</td>
     <td>June 15th</td>
     <td>75</td>
     <td>1,204 ft</td>
     <td>29,686</td>
     <td>4/5</td>
  </tr>
  <tr>
     <td>Magic City, ID</td>
     <td>June 25th</td>
     <td>74</td>
     <td>5,312 ft</td>
     <td>50</td>
     <td>3/5</td>
  </tr>
 </table>
</body>
</html>
easement
thanx mate.It works now
SourceC
+1  A: 

I've only tested it on IE6 (sorry - I'm not on my machine) but I think your text editor has inserted 'smart quotes' around the double-quotes strings instead of the straight ones. It seems like just a stylistic change but it is a different character (&ldquo;\&rdquo; instead of &quot;). When I replaced them it rendered the borders.