Which CSS selector should you use?

You develop an HTML application that contains a table that displays a list of products. The
table is defined with the following HTML markup:

You must style the table to look like the following image:

You need to implement the CSS selectors to select the rows that must have a blue
background.
Which CSS selector should you use?

You develop an HTML application that contains a table that displays a list of products. The
table is defined with the following HTML markup:

You must style the table to look like the following image:

You need to implement the CSS selectors to select the rows that must have a blue
background.
Which CSS selector should you use?

A.
thead:only-child, tbody:after, table:before

B.
tr [line |-0, 1, 3]

C.
tr:first-of-type, tr:last-of-type

D.
tr:first-line, tr:last-child

Explanation:

Header (line 0), first line and third line.



Leave a Reply 3

Your email address will not be published. Required fields are marked *

15 − two =


freedeveloper

freedeveloper

Answer is C:

B has not sense.
Product is the first of the type and last of the type for thead element
and Adjustable Race and Down Tube is the first and last element tr of tbody.

More information at
http://stackoverflow.com/questions/29201561/is-there-syntax-for-a-tr-line-specific-css-selector

Aires

Aires

True, the answer B is not even usable, i can’t seem to understand how and why would people choose that answer. I have tested both and the only one that actually works is option C. I will put the code for those who won’t believe.

tr:first-of-type, tr:last-of-type
{
background-color: blue;
}

Product

Adjustable Race

Blade

Chainring

Down Tube