How to Change the Background Color of Table using CSS? Last Updated : 30 Jul, 2024 Comments Improve Suggest changes Like Article Like Report Changing the background color of a table using CSS can help improve the visual appearance of a website or web application. we will learn how to change the background color of the table using CSS with different approaches.These are the following approaches:Table of Content Using Inline CSSUsing Internal CSSUsing Inline CSSIn this approach, we are using Inline CSS which involves applying styles directly to HTML elements using the style attribute. To change the background color of a table using inline CSS, we can use the background-color property.Syntax:<table style="background-color: colorName;"> <!-- table content --></table>Example: The below example uses the Inline CSS to Change the Background Color of Table. HTML <!DOCTYPE html> <html> <head> <title>Inline CSS Example</title> </head> <body> <table style="background-color: yellow;" border="1"> <thead> <tr> <th>First Name</th> <th>Last Name</th> <th>Age</th> </tr> </thead> <tbody> <tr> <td>Virat</td> <td>Kohli</td> <td>39</td> </tr> <tr> <td>MS</td> <td>Dhoni</td> <td>47</td> </tr> <tr> <td>Rohit</td> <td>Sharma</td> <td>35</td> </tr> </tbody> </table> </body> </html> Output:Using Internal CSSIn this approach we are using internal CSS to change the background color of a table, Here we define the CSS styles within a <style> tag and we set the background-color property of the table to the desired color.Example: The below example uses the Internal CSS to Change the Background Color of Table. HTML <!DOCTYPE html> <html> <head> <title>Internal CSS Example</title> <style> table { width: 100%; border-collapse: collapse; background-color: lightblue; } th, td { border: 1px solid black; padding: 8px; text-align: center; } </style> </head> <body> <table> <thead> <tr> <th>First Name</th> <th>Last Name</th> <th>Age</th> </tr> </thead> <tbody> <tr> <td>Virat</td> <td>Kohli</td> <td>39</td> </tr> <tr> <td>MS</td> <td>Dhoni</td> <td>47</td> </tr> <tr> <td>Rohit</td> <td>Sharma</td> <td>35</td> </tr> </tbody> </table> </body> </html> Output: Comment More infoAdvertise with us Next Article How to Change the Background Color of Table using CSS? Y yuvrajghule281 Follow Improve Article Tags : HTML CSS-Questions Similar Reads How to Change Background Color in HTML without CSS ? In HTML, you can change the background color of an element using the bgcolor attribute. However, it's important to note that the bgcolor attribute is deprecated in HTML5 and should be avoided in favor of using CSS for styling. This article will cover various methods to change the background color of 2 min read How to change Background Color in HTML ? The background color in HTML sets the visual backdrop behind your webpage content. Around 85% of beginner developers start by customizing background colors to enhance design and readability. Using CSS (Cascading Style Sheets), you can easily apply colors through the background-color property. This c 3 min read How To Set Alternate Table Row Color Using CSS? To set alternate table row colors, we can use the :nth-child() pseudo-class in CSS. This technique helps improve the readability of a table by making it easier to differentiate between rows. In this article, we'll cover how to set alternate row colors using the :nth-child() pseudo-class and provide 3 min read Set Background Color using CSS Setting the background color in CSS involves using the background-color property to define the color displayed behind the content within an HTML element. This can be achieved through three primary methods: inline CSS, internal CSS, and external CSS. Each method offers different advantages depending 4 min read How to Change Background Color in Google Docs : Easy Steps to Follow How to Change Background Color on Google Docs - Quick Steps Open Google Docs > Choose a DocumentGo to File > Select Page SetupClick on Page Color > Choose ColorClick "Ok"Changing the background color in Google Docs is a simple yet effective way to personalize your documents and make them vi 7 min read Like