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!
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?
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;
}
0
Its four cellsâŠ
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