Are there an easy way to color all cells of a table? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Are there an easy way to color all cells of a table?

<table> <tr> <td bgcolor="red">Red</td> <td bgcolor="red">Red</td> <td bgcolor="red">Red</td> </tr> </table> too long XD

1st Feb 2017, 9:28 AM
prayoga
prayoga - avatar
2 Answers
+ 2
You can quickly benefit from inherit behaviour of CSS ( Cascading Style Sheets ), by inlining them through the 'style' attribute oh html tags: <table> <tr style="background:red;"> <!-- behaviour of <tr> is to apply style to childs <td> --> <td>red</td> <td>red</td> <td>red</td> </tr> <tr style="background:red;"> <!-- 'background' is shorthand property can be used for color --> <!-- ... --> </tr> </table> Keep just in mind that's inlined css are to be avoided, even you can make some exceptions, like for testing/debuging purposes, else externalized css ( in <style> tag or referenced in <link> tag as external file ) are to be prefered ;)
1st Feb 2017, 9:47 AM
visph
visph - avatar
+ 1
you must learn and use css to do this. ex: td{ background-color:red; }
1st Feb 2017, 9:30 AM
Nguyễn Hoàng Long
Nguyễn Hoàng Long - avatar