Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 82
  • Last Modified:

adding css to certains rows of a html table

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
maqskywalker
Asked:
maqskywalker
  • 2
2 Solutions
 
Thomas WheelerCommented:
you want to use
tr > td:first-child 

Open in new window

check this out https://jsfiddle.net/wgrk1xpf/
0
 
Thomas WheelerCommented:
after rereading I may have miss understood. Here is an update
https://jsfiddle.net/wgrk1xpf/1/
0
 
Russ SuterCommented:
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
 
maqskywalkerAuthor Commented:
Thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now