0
Table background color inheritance
In my code (html:27-30, css:150-157) I used a table, but it seems like the background of the <td> elements is inherited by the <tr> elements. Is it possible to give every <td> another background color without changing the <tr>'s background? https://code.sololearn.com/WOFHWpaKq8k2/?ref=app
4 Answers
+ 2
I’m not an expert of web design but I think you can put this in HTML to change the color you want (In this example red).
<table>
<tr>
<td bgcolor="red">Something</td>
</tr>
</table>
+ 1
Aprendrox is right
td{
background-color:red;
}
0
But why does it not work when calling the id's / classes that I gave them?
or when I put bgcolor="" in the html
and what is the difference between background and background-color. I mostly use background 'cause I'm lazy
0
Roel I think this will help you, I found it on internet:
Background actually is a shorthand for
background-color
background-image
background-position
background-repeat
background-attachment
background-clip
background-origin
background-size
Thus, besides the background-color, using the background shortcut you could also add one or more values without repeating any other background-* property more than once.
But it could also depend on specific conditions of your style declarations (e.g if you need to override just the background-color when inheriting other related background-* properties from a parent element, or if you need to remove all the values except the background-color).