Toggle navigation
☰
Home
HTML
CSS
Scripting
Database
<!DOCTYPE html> <title>My Example</title> <style> .column-hiding-table { width: 100%; border-collapse: collapse; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; } .column-hiding-table thead th { padding: 12px 10px; background-color: #f8f9fa; border-bottom: 2px solid #dee2e6; text-align: left; font-weight: 600; } .column-hiding-table tbody td { padding: 12px 10px; border-bottom: 1px solid #e9ecef; } .column-hiding-table tbody tr:hover { background-color: #f8f9fa; } /* By default, all columns are visible. The logic is in the media query below. The .hide-on-mobile class itself does nothing on desktop screens. */ /* --- Responsive Logic --- */ /* This media query targets screens 768px wide or smaller */ @media screen and (max-width: 768px) { /* The magic happens here: hide elements with this class */ .hide-on-mobile { display: none; } } </style> <!-- INSTRUCTIONS: To hide a column, add the class "hide-on-mobile" to BOTH the header (th) and every data cell (td) in that column. View on a small screen or shrink your browser to see the effect. --> <table class="column-hiding-table"> <thead> <tr> <!-- This column is less important and will be hidden on mobile --> <th scope="col" class="hide-on-mobile">User ID</th> <th scope="col">Name</th> <th scope="col">Role</th> <!-- This column is less important and will be hidden on mobile --> <th scope="col" class="hide-on-mobile">Sign-up Date</th> <th scope="col">Status</th> </tr> </thead> <tbody> <tr> <!-- This data cell will be hidden on mobile --> <td class="hide-on-mobile">9812</td> <td>Alex Chen</td> <td>Administrator</td> <!-- This data cell will be hidden on mobile --> <td class="hide-on-mobile">2023-05-11</td> <td>Active</td> </tr> <tr> <td class="hide-on-mobile">9954</td> <td>Brenda Morales</td> <td>Editor</td> <td class="hide-on-mobile">2023-08-01</td> <td>Active</td> </tr> <tr> <td class="hide-on-mobile">10023</td> <td>Carlos Pinto</td> <td>Contributor</td> <td class="hide-on-mobile">2024-01-20</td> <td>Pending</td> </tr> <tr> <td class="hide-on-mobile">10156</td> <td>Diana Rodriguez</td> <td>Editor</td> <td class="hide-on-mobile">2024-02-15</td> <td>Inactive</td> </tr> </tbody> </table>