I have an HTML table as below :
<table class="reference notranslate">
<tr>..</tr>
.
.
<tr>..</tr>
</table>
<table class="reference notranslate">
<tr>..</tr>
.
.
<tr>..</tr>
</table>
<table class="reference notranslate">
<tr>..</tr>
.
.
<tr>..</tr>
</table>
I know the XPATH : //table[@class = 'reference notranslate'][2]/tr[2]
I want to select second table's second row. Can any one help how to write the CSS selectors from the same?
In the style, the "tr" selects the even table rows. You can use this css to select every other paragraph by changing the css to "p:nth-child(even)", or list items: li:nth-child(even), etc. Change "even" to "odd" if you want the shading to affect odd rows.
When you group CSS selectors, you apply the same styles to several different elements without repeating the styles in your stylesheet. Instead of having two, three, or more CSS rules that do the same thing (set the color of something to red, for example), you use a single CSS rule that accomplishes the same thing.
"I know the XPATH :
//table[@class = 'reference notranslate'][2]/tr[2]
I want to select second table's second row. Can any one help how to write the CSS selectors from the same?"
So, you mean like:
table.reference.notranslate:nth-child(2) tr:nth-child(2)
This selects the second descendant tr
element of the second table which has both classes (reference
and notranslate
).
jsFiddle here.
table.reference:nth-of-type(2) tr:nth-child(2)
{
background-color:red;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With