How to Set Background Image in HTML Table ? Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report Setting a background image in an HTML table can enhance the visual appeal of your webpage. In this article, we will discuss two methods to set a background image in an HTML table i.e. using inline CSS and external CSS. Set Background Image in HTML Table using Inline CSSIn this approach, we directly apply the CSS style to the <table> tag using the style attribute. HTML <!DOCTYPE html> <html> <head> <title>Background Image in Table</title> <style> table { margin: auto; } table, tr td { border: 1px solid black; } </style> </head> <body> <table style="background-image: url('https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png'); width: 400px; height: 200px;"> <tr> <td>Cell 1</td> <td>Cell 2</td> </tr> <tr> <td>Cell 3</td> <td>Cell 4</td> </tr> <tr> <td>Cell 3</td> <td>Cell 4</td> </tr> <tr> <td>Cell 3</td> <td>Cell 4</td> </tr> </table> </body> </html> Output ExplanationThe background-image property is used to set the image as the background of the table.The url() function is used to specify the path of the image file.The width and height properties are used to set the size of the table.Set Background Image in HTML Table using External CSSIn this method, we use an external CSS file to style the table. This approach is more maintainable and scalable. HTML <!DOCTYPE html> <html> <head> <title>Background Image in Table</title> <link rel="stylesheet" href="style.css"> </head> <body> <table class="background-table"> <tr> <td>Cell 1</td> <td>Cell 2</td> </tr> <tr> <td>Cell 3</td> <td>Cell 4</td> </tr> <tr> <td>Cell 3</td> <td>Cell 4</td> </tr> <tr> <td>Cell 3</td> <td>Cell 4</td> </tr> </table> </body> </html> CSS /* Filename: style.css */ table { margin: auto; } table, tr td { border: 1px solid black; } .background-table { background-image: url('https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png'); width: 400px; height: 200px; } Output: ExplanationThe .background-table class is defined in the external CSS file styles.css.The background-image property is used to set the image as the background of the table.The width and height properties are used to set the size of the table.The class is applied to the <table> tag in the HTML file. Comment More infoAdvertise with us Next Article How to Set Background Image in HTML Table ? V vkash8574 Follow Improve Article Tags : HTML HTML-Questions Similar Reads How to Add Image in HTML Table ? Adding images to an HTML table can enhance the visual appeal and functionality of your webpage. Whether it is for displaying product images in an e-commerce website or adding profile pictures in a user list, images in tables are a common requirement. In this article, we will explore two methods to a 2 min read How to Add Background Image in HTML? Adding a background image to an HTML page can enhance the visual appeal and provide a more immersive experience for your website visitors. The <body> background attribute is used to add a background image in HTML, but this attribute is deprecated in HTML5 and is not in use. In place of the bac 3 min read How to Set Background Image in CSS? CSS (Cascading Style Sheets) can allow developers to set the background image for the web pages or specific HTML elements. This feature can help enhance the visual aesthetics of the website. The background-image property in CSS can be used to specific one or multiple background images to be applied 3 min read How to insert Background Image in HTML From Local Folder ? Adding a background image to your HTML page can enhance its visual appeal and make it more engaging for users. When the image is stored in a local folder, you can easily reference it in your HTML file using relative or absolute paths. Table of Content Using Inline CSSUsing Internal CSSUsing Inline C 2 min read How to Add Image inside Table Cell in HTML ? Adding images inside HTML table cells can enhance the visual appeal of your tables by up to 60%, making your content more engaging and easier to understand. This approach allows you to effectively present visuals alongside text for better communication and user experience.Image inside Table CellThes 2 min read Like