W3.CSS provides a series of classes that can be used to apply various styling to the tables such as changing the heading appearance, making the rows stripped, adding or removing borders, making rows hoverable, etc. W3.CSS also provides classes for making tables responsive.
Simple Table: The .w3-table class is used to create a simple W3.CSS table. This class name is used with <table> tag to create a table.
Syntax:
<table class="w3-table"> Table Contents... <table>
Example:
HTML <!DOCTYPE html> <html> <head> <!-- Adding W3.CSS file through external link --> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> </head> <body> <!-- w3-container is used to add 16px padding to any HTML element. --> <!-- w3-center is used to set the content of the element to the center. --> <div class="w3-container w3-center"> <!-- w3-text-green sets the text color to green. --> <!-- w3-xxlarge sets font size to 32px. --> <h2 class="w3-text-green w3-xxlarge"> GeeksForGeeks </h2> </div> <!-- Adding a table at the center of the page --> <div class="w3-container w3-center"> <table class="w3-table"> <!-- Table Heading --> <thead> <tr> <th>Sr. No.</th> <th>Name</th> <th>City</th> <th>Age</th> </tr> </thead> <!-- Table Body or Content --> <tbody> <tr> <th>1</th> <td>Ajay</td> <td>Patna</td> <td>20</td> </tr> <tr> <th>2</th> <td>Rahul</td> <td>Chandigarh</td> <td>17</td> </tr> <tr> <th>3</th> <td>Parush</td> <td>Kolkata</td> <td>22</td> </tr> </tbody> </table> </div> </body> </html>
Output:

Stripped rows: The .w3-stripped class is used to create an alternate dark and light rows. Use the combination of table, w3-table, and w3-stripped classes within the <table> tag to create a stripped table.
Syntax:
<table class="w3-table w3-stripped"> Table Contents... <table>
Example:
HTML <!DOCTYPE html> <html> <head> <!-- Title of the page --> <title>GeeksForGeeks</title> <!-- Adding W3.CSS file through external link --> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> </head> <body> <!-- w3-container is used to add 16px padding to any HTML element. --> <!-- w3-center is used to set the content of the element to the center. --> <div class="w3-container w3-center"> <!-- w3-text-green sets the text color to green. --> <!-- w3-xxlarge sets font size to 32px. --> <h2 class="w3-text-green w3-xxlarge"> GeeksForGeeks </h2> </div> <!-- Adding a table at the center of the page --> <div class="w3-container w3-center"> <table class="w3-table w3-stripped"> <!-- Table Headings --> <tr> <th>Sr. No.</th> <th>Name</th> <th>City</th> <th>Age</th> </tr> <!-- Table Content --> <tr> <th>1</th> <td>Ajay</td> <td>Patna</td> <td>20</td> </tr> <tr> <th>2</th> <td>Rahul</td> <td>Chandigarh</td> <td>17</td> </tr> <tr> <th>3</th> <td>Parush</td> <td>Kolkata</td> <td>22</td> </tr> </table> </div> </body> </html>
Output:

Bordered Table: The .w3-border is used to add a border across the table. The border only occurs around the table and not in the table. The see this effect use .w3-border together with .w3-table in the table tag.
Syntax:
<table class="w3-table w3-border"> Table Contents... <table>
Example:
HTML <!DOCTYPE html> <html> <head> <!-- Title of the page --> <title>GeeksForGeeks</title> <!-- Adding W3.CSS file through external link --> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> </head> <body> <!-- w3-container is used to add 16px padding to any HTML element. --> <!-- w3-center is used to set the content of the element to the center. --> <div class="w3-container w3-center"> <!-- w3-text-green sets the text color to green. --> <!-- w3-xxlarge sets font size to 32px. --> <h2 class="w3-text-green w3-xxlarge">GeeksForGeeks</h2> </div> <!-- Adding a table at the center of the page --> <div class="w3-container w3-center"> <table class="w3-table w3-border"> <!-- Table Headings --> <tr> <th>Sr. No.</th> <th>Name</th> <th>City</th> <th>Age</th> </tr> <!-- Table Content --> <tr> <th>1</th> <td>Ajay</td> <td>Patna</td> <td>20</td> </tr> <tr> <th>2</th> <td>Rahul</td> <td>Chandigarh</td> <td>17</td> </tr> <tr> <th>3</th> <td>Parush</td> <td>Kolkata</td> <td>22</td> </tr> </table> </div> </body> </html>
Output:

If we want a completely bordered table we have to use .w3-bordered class along with .w3-border and w3-table inside the table tag.
Example:
HTML <!DOCTYPE html> <html> <head> <!-- Adding W3.CSS file through external link --> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> </head> <body> <!-- w3-container is used to add 16px padding to any HTML element. --> <!-- w3-center is used to set the content of the element to the center. --> <div class="w3-container w3-center"> <!-- w3-text-green sets the text color to green. --> <!-- w3-xxlarge sets font size to 32px. --> <h2 class="w3-text-green w3-xxlarge"> GeeksForGeeks </h2> </div> <!-- Adding a table at the center of the page --> <div class="w3-container w3-center"> <table class="w3-table w3-border w3-bordered"> <!-- Table Headings --> <tr> <th>Sr. No.</th> <th>Name</th> <th>City</th> <th>Age</th> </tr> <!-- Table Content --> <tr> <th>1</th> <td>Ajay</td> <td>Patna</td> <td>20</td> </tr> <tr> <th>2</th> <td>Rahul</td> <td>Chandigarh</td> <td>17</td> </tr> <tr> <th>3</th> <td>Parush</td> <td>Kolkata</td> <td>22</td> </tr> </table> </div> </body> </html>
Output:

Hoverable Table: The .w3-hoverable class is used to add a hover effect (change background color to gray when the mouse moves over) on table rows. Use the combination of w3-table and w3-hoverable classes within the <table> tag to create a hover rows table.
Syntax:
<table class="w3-table w3-hoverable"> Table Contents... <table>
Example:
HTML <!DOCTYPE html> <html> <head> <!-- Title of the page --> <title>GeeksForGeeks</title> <!-- Adding W3.CSS file through external link --> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> </head> <body> <!-- w3-container is used to add 16px padding to any HTML element. --> <!-- w3-center is used to set the content of the element to the center. --> <div class="w3-container w3-center"> <!-- w3-text-green sets the text color to green. --> <!-- w3-xxlarge sets font size to 32px. --> <h2 class="w3-text-green w3-xxlarge">GeeksForGeeks</h2> </div> <!-- Adding a table at the center of the page --> <div class="w3-container w3-center"> <table class="w3-table w3-hoverable"> <!-- Table Headings --> <tr> <th>Sr. No.</th> <th>Name</th> <th>City</th> <th>Age</th> </tr> <!-- Table Content --> <tr> <th>1</th> <td>Ajay</td> <td>Patna</td> <td>20</td> </tr> <tr> <th>2</th> <td>Rahul</td> <td>Chandigarh</td> <td>17</td> </tr> <tr> <th>3</th> <td>Parush</td> <td>Kolkata</td> <td>22</td> </tr> </table> </div> </body> </html>
Output:

Centered Content Table: The .w3-centered class is used to place all the content of the table to the center. Use the combination of w3-table and w3-centered classes within the <table> tag to create this effect.
Syntax:
<table class="w3-table w3-centered"> Table Contents... <table>
Example:
HTML <!DOCTYPE html> <html> <head> <!-- Adding W3.CSS file through external link --> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> </head> <body> <!-- w3-container is used to add 16px padding to any HTML element. --> <!-- w3-center is used to set the content of the element to the center. --> <div class="w3-container w3-center"> <!-- w3-text-green sets the text color to green. --> <!-- w3-xxlarge sets font size to 32px. --> <h2 class="w3-text-green w3-xxlarge">GeeksForGeeks</h2> </div> <!-- Adding a table at the center of the page --> <div class="w3-container w3-center"> <table class="w3-table w3-centered"> <!-- Table Headings --> <tr> <th>Sr. No.</th> <th>Name</th> <th>City</th> <th>Age</th> </tr> <!-- Table Content --> <tr> <th>1</th> <td>Ajay</td> <td>Patna</td> <td>20</td> </tr> <tr> <th>2</th> <td>Rahul</td> <td>Chandigarh</td> <td>17</td> </tr> <tr> <th>3</th> <td>Parush</td> <td>Kolkata</td> <td>22</td> </tr> </table> </div> </body> </html>
Output:

Now, if you want to select all the above effects all together on a table then you can use w3-table-all class. This class is used to select all the properties of the table i.e border, stripped, table,... You have to use this class with table tag to see the effect.
Example:
HTML <!DOCTYPE html> <html> <head> <!-- Adding W3.CSS file through external link --> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> </head> <body> <!-- w3-container is used to add 16px padding to any HTML element. --> <!-- w3-center is used to set the content of the element to the center. --> <div class="w3-container w3-center"> <!-- w3-text-green sets the text color to green. --> <!-- w3-xxlarge sets font size to 32px. --> <h2 class="w3-text-green w3-xxlarge">GeeksForGeeks</h2> </div> <!-- Adding a table at the center of the page --> <div class="w3-container w3-center"> <table class="w3-table-all"> <!-- Table Headings --> <tr> <th>Sr. No.</th> <th>Name</th> <th>City</th> <th>Age</th> </tr> <!-- Table Content --> <tr> <th>1</th> <td>Ajay</td> <td>Patna</td> <td>20</td> </tr> <tr> <th>2</th> <td>Rahul</td> <td>Chandigarh</td> <td>17</td> </tr> <tr> <th>3</th> <td>Parush</td> <td>Kolkata</td> <td>22</td> </tr> </table> </div> </body> </html>
Output:
Similar Reads
CSS Tables
CSS tables are used to style HTML tables, making them look neat and organized for clear data presentation. Add borders, spacing, and colors to enhance table design.Create responsive tables that adjust for all screen sizes.[GFGTABS] HTML <html> <head> <style> table { width: 50%; bor
6 min read
W3.CSS Tags
The .w3-tag is used to add additional information to the content. For example, some website highlights some sections to be new or when they have updated a section they add updated tag with that division so that user can see that they have updated to added new divisions on their site. This class when
4 min read
W3.CSS Lists
Lists are very useful in a webpage. It can be used a variety of content as they are flexible and easy to manage. We use .w3-ul class for the list. The default style for the list is borderless but we can use other classes to add a border and other effects to the list. Example: Adding a list on a webp
5 min read
Pure CSS Tables
Introduction: Before starting with Pure we must know the basics of plain CSS. Basically, Pure CSS is a Cascading Style Sheet framework developed by YAHOO. The main reason for developing Pure CSS is used to develop responsive and reactive websites like Bootstrap which is also compatible with mobile d
5 min read
Primer CSS Tables
Primer CSS is a free open-source CSS framework that is built upon systems that create the foundation of the basic style elements such as spacing, typography, and color. This systematic method makes sure our patterns are steady and interoperable with every other. Its approach to CSS is influenced by
2 min read
CSS Examples
CSS Examples showcase various styling techniques for HTML elements. They display properties, selectors, and functions that enhance design and creativity. This section offers categorized programming examples that cover properties, selectors, and functions. It provides multiple solutions for styling H
2 min read
W3.CSS Margin
W3.CSS has many facilities of classes to easily style elements in HTML. It includes various responsive margin classes for modification of the appearance of the element. The list of margin classes are as follows: Sr. No. Class Name Description 1. w3-margin It adds 16px of margin to all the sides of t
2 min read
Foundation CSS Tables
Foundation CSS is an open-source and responsive front-end framework built by ZURB foundation in September 2011, that makes it easy to design beautiful responsive websites, apps, and emails that look amazing and can be accessible to any device. It is used by many companies such as Facebook, eBay, Moz
5 min read
W3.CSS Padding
W3.CSS has many facilities of classes to easily style elements in HTML. It includes various responsive padding classes for modification of the appearance of the element. There are two types of padding classes: Numbered Padding ClassesSized Padding Classes Numbered Padding Classes: These classes add
3 min read
Tailwind CSS Table Layout
This class accepts lots of value in tailwind CSS in which all the properties are covered in class form. By using this class we can set the display of the layout of the table. In CSS, we do that by using the CSS table-layout property. Table Layout classes: table-autotable-fixed table-auto: This class
2 min read