Solved

adding css to certains rows of a html table

Posted on 2016-07-15
5
61 Views
Last Modified: 2016-07-16
I have a html table called Table 1

#Table1 td {     border: 1px solid #0000ff; }

That css says color the border of every column in the table.

How would i do the following?

Color the border of every column in Table 1 that is not in row 1
Color the border this color #0000ff
0
Comment
Question by:maqskywalker
  • 2
5 Comments
 
LVL 7

Expert Comment

by:Thomas Wheeler
ID: 41713561
you want to use
tr > td:first-child 

Open in new window

check this out https://jsfiddle.net/wgrk1xpf/
0
 
LVL 7

Assisted Solution

by:Thomas Wheeler
Thomas Wheeler earned 250 total points
ID: 41713567
after rereading I may have miss understood. Here is an update
https://jsfiddle.net/wgrk1xpf/1/
0
 
LVL 20

Accepted Solution

by:
Russ Suter earned 250 total points
ID: 41713639
Put this in your CSS
#table1 tr:nth-child(n+2) td
{
   border: 1px solid #0000ff;
}

Open in new window

This will set the border of any <td> element inside any <tr> element that is the 2nd or greater child of the <table id="table1"> element.
It will ignore the 1st row and no other CSS is needed to format your table this way.
Here's a handy website that gives you a fairly thorough set of examples of what the nth-child CSS selector can do: http://nthmaster.com/
0
 
LVL 1

Author Closing Comment

by:maqskywalker
ID: 41714822
Thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

820 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