DataTable does not work with Bootstrap 5 dependency

DataTable does not work with Bootstrap 5 dependency

MHVMHV Posts: 2Questions: 1Answers: 0

The third time is the charm, hopefully, I'll be able to post a question. I got a problem with Bootstrap 5 and Datatables. The dependency that is added for Datatables ruins the rest of the design with Bootstrap 5. If I remove the Datatable dependency, it magically works normally again. How can I fix this issue? Sorry for my ignorance, frontend is not my strong point at all.

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- Stylesheet & Bootstrap --->
    <link rel="stylesheet" href="../stylesheet/stylesheet.css">
    <link rel="stylesheet" href="../lib/bootstrap/css/bootstrap.min.css">

    <!-- DataTables dependency --->
    <script src=""></script>
    <script src=""></script>
    <script src=""></script>
    <link rel="stylesheet" href="" />
    <link rel="stylesheet" href="" />


<body class="bg-light">
<nav class="navbar navbar-expand-lg navbar-dark py-3 bg-dark">
    <a class="navbar-brand fs-3" href="#">PHP project</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    <div class="collapse navbar-collapse justify-content-end" id="navbarNav">
        <ul class="navbar-nav fs-5">
            <li class="nav-item active">
                <a class="nav-link" href="#">Home <span class="sr-only"></span></a>
            <li class="nav-item">
                <a class="nav-link" href="#">Register</a>
            <li class="nav-item">
                <a class="nav-link" href="#">Login</a>

<!---DataTable implementation--->
<div class="container">
<table id="userInformation" class="table table-striped table-bordered" style="width:100%">
    <!--- Innholdet over table --->
    while ($row = mysqli_fetch_array($result)) {
        echo '  


<!--- JavaScript(?) for DataTables--->


This question has an accepted answers - jump to answer


  • kthorngrenkthorngren Posts: 13,816Questions: 25Answers: 3,252
    Answer ✓

    I'm not sure what Bootstrap version line 10 is loading: ../lib/bootstrap/css/bootstrap.min.css.

    In your "Datatables dependency" section you are loading Bootstrap 3 CSS ( 3.3.6/css/bootstrap.min.css ) and the Datatables styling for Bootstrap 3.

    You will probably want to remove line 16 assuming line 10 is Bootstrap 5. Use the Download Builder to get the proper files for the Bootstrap 5 styling.


  • MHVMHV Posts: 2Questions: 1Answers: 0

    Thanks a lot for the help. I got the "downloads/links" from an older project that used Datatables. The ../lib/bootstrap/css/bootstrap.min.css is a local Bootstrap 5 download because of bad internet. Thanks again, you're a lifesaver :smile:

Sign In or Register to comment.