Data table bootstrap using JS, HTML, CSS

Data table bootstrap using JS, HTML, CSS

Step 1: Create index.html

In this step, we will create a basic HTML page and load the necessary libraries for Bootstrap and DataTables.

Here’s the complete index.html file:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Data Table Example</title> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <!-- DataTables CSS --> <link rel="stylesheet" href="https://cdn.datatables.net/1.10.22/css/dataTables.bootstrap.min.css"> <link rel="stylesheet" href="https://cdn.datatables.net/fixedheader/3.1.7/css/fixedHeader.bootstrap.min.css"> <link rel="stylesheet" href="https://cdn.datatables.net/responsive/2.2.6/css/responsive.bootstrap.min.css"> </head> <body> <div class="container"> <h2>Employee List</h2> <table id="example" class="table table-striped table-bordered nowrap" style="width:100%"> <thead> <tr> <th>Name</th> <th>Position</th> <th>Office</th> <th>Age</th> <th>Start Date</th> <th>Salary</th> </tr> </thead> <tbody> <!-- Example Data Rows --> <tr> <td>Tiger Nixon</td> <td>System Architect</td> <td>Edinburgh</td> <td>61</td> <td>2011/04/25</td> <td>$320,800</td> </tr> <tr> <td>Garrett Winters</td> <td>Accountant</td> <td>Tokyo</td> <td>63</td> <td>2011/07/25</td> <td>$170,750</td> </tr> <tr> <td>Ashton Cox</td> <td>Junior Technical Author</td> <td>San Francisco</td> <td>66</td> <td>2009/01/12</td> <td>$86,000</td> </tr> <!-- Add more rows as needed --> </tbody> </table> </div> <!-- jQuery --> <script src="https://code.jquery.com/jquery-3.5.1.js"></script> <!-- Bootstrap JS --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <!-- DataTables JS --> <script src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.min.js"></script> <script src="https://cdn.datatables.net/1.10.22/js/dataTables.bootstrap.min.js"></script> <script src="https://cdn.datatables.net/fixedheader/3.1.7/js/dataTables.fixedHeader.min.js"></script> <script src="https://cdn.datatables.net/responsive/2.2.6/js/dataTables.responsive.min.js"></script> <script src="https://cdn.datatables.net/responsive/2.2.6/js/responsive.bootstrap.min.js"></script> <!-- DataTables Initialization --> <script> $(document).ready(function() { var table = $('#example').DataTable({ responsive: true }); new $.fn.dataTable.FixedHeader(table); }); </script> </body> </html>

✅ In this version:

  • I kept only a few rows of the employee table to make it short (you can add more easily).

  • All required CSS and JS links are correctly included.

  • A simple JavaScript initialization for DataTables and FixedHeader is added at the bottom.

Soeng Souy

Soeng Souy

Website that learns and reads, PHP, Framework Laravel, How to and download Admin template sample source code free.

Post a Comment

CAN FEEDBACK
close