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? 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 How to Set Transparent Background Color in CSS ? Creating a simple transparent background involves styling HTML elements using CSS to achieve the desired visual effect. We can use different approaches to achieve this effect including, RGBA color values and the Opacity property. Below are the approaches to set transparent background color in CSS: T 2 min read How to Add Background Color in Input and Text Fields using CSS ? In this article, we will explore different approaches to adding background color to input and text fields using CSS. Customizing the appearance of input and text fields is an essential aspect of web design, and changing the background color is a powerful way to enhance the visual appeal of these ele 2 min read How to put the caption below the table using CSS ? In this article we are going to learn How to put the caption below the table using CSS, To put the caption below the table we can use the CSS caption-side property. This property is used to specify the position where the table caption is placed. It is used in HTML Tables. This property can be used w 1 min read How to Hide Border and Background on Empty Cells in a Table using CSS? In this article, we will learn how to hide borders and backgrounds on empty cells in a table using CSS. The empty-cells property of CSS is used to hide the borders and backgrounds on empty cells.Approach To Hide Border and Background on Empty Cells In A TableThe empty-cells: hide; style of the .gfg 1 min read Like