I have a simple project with that files structure:
But my CSS and JS files are not loading...
<link rel="stylesheet" href="./css/main.css">
<script src="./js/main.js"></script>
CodePudding user response:
May be this should work :
<link rel="stylesheet" href="css/main.css">
<script src="js/main.js"></script>
CodePudding user response:
the below should works:
<link rel="stylesheet" href="../css/main.css">
<script src="../js/main.js"></script>
Add two dots instead of one.
For more information read: https://www.w3schools.com/html/html_filepaths.asp
CodePudding user response:
It should be work
<link rel="stylesheet" href="/www/public/css/main.css" type="text/css">
<script type="text/javascript" src="/www/public/js/main.js"></script>
CodePudding user response:
Conclusion. I managed to solve the problem. But I had to point to the entire root of the directories. This way it worked.
<head>
<title>Title</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg p" crossorigin="anonymous"/>
<link rel="stylesheet" href="./www/public/css/main.css">
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM B07jRM" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.16/jquery.mask.min.js" integrity="sha512-pHVGpX7F/27yZ0ISY VVjyULApbDlD0/X0rgGbTqCE7WFW5MezNTWG/dnhtbBuICzsd0WQPgpE4REBLv UqChw==" crossorigin="anonymous"></script>
<script src="./www/public/js/main.js"></script>