Solved

css

Posted on 2007-03-21
5
260 Views
Last Modified: 2010-04-09
Hi,

Please assist is it possible to add name to a <TD> so that it would change the color depending o n the TD's name? I'd like to know how can we add it in the CSS file below.

<table name ="old">
<tr>
<td name="red">this background will now turn red
</td><td>normal</td>
</tr>
</table>

Thanks


table #old ,#old td,#old th{
      font-size:100%;
      font-family: Arial;
      border:1px solid #666;
      border-collapse:collapse;
      margin:0;
      padding:0;
}
#old td,#old th{
      font-size:90%;
      padding:.2em .5em;
      font-weight:bold;
      vertical-align:top;
      font-weight:normal;
}
#old thead th{
      font-weight:bold;
      font-family: Arial;
      background:#FFD735;
      font-size: 11px;
      color:black;
}
#old tbody td{
      font-size:70%;
      background:#ccc;
}
#old tbody th{
      font-size:70%;
      background:#999;
}
#old tbody tr.odd td{
      font-size:70%;
      background:#eee;
}
#old tbody tr.odd th{
      font-size:70%;
      background:#ccc;
}
#old caption {
      background:#666;
      color:#fff;
      font-weight:bold;
      text-align:left;
      font-size:75%;
}
0
Comment
Question by:FrankPorter
  • 3
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
under_dog earned 500 total points
Comment Utility
You want to give the TD a class rather than a name like:

<table name ="old">
<tr>
<td class="red">this background will now turn red
</td><td>normal</td>
</tr>
</table>

and then add this to your styles:

.red {

  background-color: red;

}
0
 

Author Comment

by:FrankPorter
Comment Utility
sad to say the color didnt change, ther must be something wrong with the declaration in the style file.

i added this to the end

.red {

  background-color: red;

}
0
 
LVL 9

Expert Comment

by:under_dog
Comment Utility
It works for me ... here is my code:

<!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>Untitled Document</title>
<style type="text/css">
      table #old ,#old td,#old th{
              font-size:100%;
              font-family: Arial;
              border:1px solid #666;
              border-collapse:collapse;
              margin:0;
              padding:0;
      }
      #old td,#old th{
              font-size:90%;
              padding:.2em .5em;
              font-weight:bold;
              vertical-align:top;
              font-weight:normal;
      }
      #old thead th{
              font-weight:bold;
              font-family: Arial;
              background:#FFD735;
              font-size: 11px;
              color:black;
      }
      #old tbody td{
              font-size:70%;
              background:#ccc;
      }
      #old tbody th{
              font-size:70%;
              background:#999;
      }
      #old tbody tr.odd td{
              font-size:70%;
              background:#eee;
      }
      #old tbody tr.odd th{
              font-size:70%;
              background:#ccc;
      }
      #old caption {
              background:#666;
              color:#fff;
              font-weight:bold;
              text-align:left;
              font-size:75%;
      }
      .red {
            background-color: red;      
      }

</style>
</head>

<body>
<table name ="old">
<tr>
<td class="red">this background will now turn red
</td><td>normal</td>
</tr>
</table>

</body>
</html>
0
 

Author Comment

by:FrankPorter
Comment Utility
what application do you use to edit web pages?
0
 
LVL 9

Expert Comment

by:under_dog
Comment Utility
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
html select on change 3 25
javascript to html map 8 37
CKEditor - will not function 7 31
Bootstrap Columns not Side-by-Side 3 10
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now