Solved

adding css to certains rows of a html table

Posted on 2016-07-15
5
46 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 6

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 6

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

705 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

19 Experts available now in Live!

Get 1:1 Help Now