View Full Version : Resolved CSS wont effect a table cell... but it works in Dreamweaver!

05-20-2010, 03:53 PM
I am trying to style a table with CSS. It all looks good except one part. I'm trying to set the widths for the table's columns by setting the widths of each of the top row's cells individually with CSS, but they don't seem to be getting effected. I'm probably just doing something wrong, but the weird part is that it works in Dreamweaver.

See the screenshot for how it's supposed to look, vs how it does:


The top is the Dreamweaver view, loosk fine (I even set the first cell's BG to black to quickly tell if it works). The bottom part is the view in Firefox (3.6.3). The cell's widths are not effected, and the first cell's BG is not styled.

Here is the css:

margin:3px 0px 2px 10px;
border-left:1px solid #D6D6D6;
border-bottom:1px solid #D6D6D6;
#search-results-table td{
border-right:1px solid #D6D6D6;
border-top:1px solid #D6D6D6;
padding:3px 0px 2px 10px;
#search-results-table .head{
padding:3px 0px 2px 10px;
#search-results-table .head #1{
#search-results-table .head #3{
#search-results-table .head #7{

And here is the HTML

<!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">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel='stylesheet' href='styles.css' type='text/css' />

<table cellpadding="0" cellspacing="0" id="search-results-table">
<tr class="head">
<td id="1">&nbsp;</td>
<td id="2"><a href="#">NAME</a></td>
<td id="3"><a href="#">CALS</a></td>
<td id="7"><a href="#">ADD</a></td>
<td><input checked="checked" type="checkbox" name="ITEM ID"/></td>
<td><a href="#">asdf</a></td>



05-20-2010, 04:17 PM
You can’t have IDs that start with a number, it has to be a basic latin character.

Oh and while we’re at it: You should use proper semantic table markup. A table consists of row groups, header cells and data cells that exactly denote the function of each element. You could save your IDs right away (if you don’t care about supporting IE 6) by using such markup:

<table id="search-results-table">
<th scope="col"></th>
<th scope="col"></th>
<th scope="col"></th>
<th scope="col"></th>

#search-results-table {border-collapse: collapse;}
#search-results-table thead th:first-child {width: 10px;}
#search-results-table thead th:first-child + th {width: 50px;}

05-20-2010, 04:20 PM
Perfect! I knew it would be something simple, thanks for the help.