Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to control row color within a HTML table for the header row using CSS

Posted on 2007-11-25
3
Medium Priority
?
800 Views
Last Modified: 2012-06-22
I am new to the CSS arena and would like to know how to control the color of the first row of a <table> so that it is a different color than then the remainder of the rows. For example:

<table>
<tr bgcolor="steelblue">
</tr>
</table>

Without using the bgcolor (which I have been told is "old school") how do I accomplish this effect?
0
Comment
Question by:lonekawboy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Expert Comment

by:Rok-Kralj
ID: 20345481
<table>
<tr style="background: #832F83;">
</tr>
</table>
0
 
LVL 13

Accepted Solution

by:
R7AF earned 300 total points
ID: 20345652
You can use <th> instead of <td>, and then put the following code in the head of the page. In this setup, the style will be applied to all <th> elements in all tables.
<style>
th { background: green; }
</style>

Open in new window

0
 
LVL 15

Assisted Solution

by:ncoo
ncoo earned 200 total points
ID: 20346212
Copy and paste the code below. Create as many tables as you like in the following way and all will have steelblue first rows on the page.
<html>
<head>
<style type="text/css">
thead tr th { 
background-color: steelblue;
}
</style>
</head>
<body>
<table>
<thead>
<tr><th>first row</th></tr>
</thead>
<tbody>
<tr><td>contents</td></tr>
</tbody>
</table>
</body>
</html>

Open in new window

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

610 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