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

13th May 2019, 8:32 AM
Roel
Roel - avatar
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>
13th May 2019, 8:46 AM
Aprendrox (Procrastinator inbound...)
Aprendrox (Procrastinator inbound...) - avatar
+ 1
Aprendrox is right td{ background-color:red; }
13th May 2019, 9:15 AM
Gordon
Gordon - avatar
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
14th May 2019, 8:06 PM
Roel
Roel - avatar
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).
23rd May 2019, 8:11 AM
Aprendrox (Procrastinator inbound...)
Aprendrox (Procrastinator inbound...) - avatar