0

Just started CSS need help with table colors and codes. Css

I am doing a homework for a college course I TE and it’s asking me to create a table which I have done it’s asking me to create a border around the table I have done that I cannot for the life of me figure out where or what to put as a code for coloring the table and making one of the sales a different color. Help!

7th Nov 2021, 3:55 PM
Yong Turner
4 Answers
+ 1
I have table, td { border-style: solid; } table { background-color: purple; } td { border-style: solid; { This has the beackground purple and i jist need one cell yellow. The gardening cell. So to do this do i start another line beginning with table tr{ background: yellow?
7th Nov 2021, 4:39 PM
Yong Turner
0
Ok so for a table you have: table tr td To color any, if you didn't use an id for tr, td or table, you can use css: table tr{ background:lime; } table td{ background:lime; } /*colours the first row only*/ table tr:nth-of-type(1){ background:lime; } You can do the same for td for example: /*colours the 3rd td*/ table td:nth-of-type(3){ background:lime; }
7th Nov 2021, 4:10 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
0
Its four cells

7th Nov 2021, 4:39 PM
Yong Turner
0
If you need only one cell, you can use: table tr:nth-of-type(x) td:nth-of-type(y){ background:red; } x and y being the row and the cell you want to color. For example, if the cell is on row 1, and the cell is the second, x = 1 y = 2 edit: i didn t test this, so it may not work
7th Nov 2021, 4:46 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar