I’m trying to just on some JavaScript practice and my file is not linked or loading with my HTML. I’ve even just put a regular script tag in my html and did a simple console "Hello World" in it and its not showing up.
I’ve tried creating a whole new javascript file and still get the error.
Here’s the code in question:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Omifood Hero Section</title>
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Rubik:wght@400;600;700&display=swap"
rel="stylesheet"
/>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-family: "Rubik", sans-serif;
color: #444;
}
.container {
margin: 0 auto;
width: 1200px;
}
header {
/* background-color: orangered; */
height: 100vh;
position: relative;
background-image: linear-gradient(
rgba(34, 34, 34, 0.6),
rgba(34, 34, 34, 0.6)
),
url(hero.jpg);
background-size: cover;
color: #fff;
}
nav {
font-size: 20px;
font-weight: 700;
display: flex;
justify-content: space-between;
padding-top: 32px;
/* background-image: linear-gradient(to right, red, blue); */
/* background-color: green; */
}
.header-container {
width: 1200px;
position: absolute;
/* In relation to PARENT size */
left: 50%;
top: 50%;
/* In relation to ELEMENT size */
transform: translate(-50%, -50%);
/* background-color: violet; */
/* text-align: center; */
}
.header-container-inner {
width: 50%;
/* background-color: blue; */
}
h1 {
font-size: 52px;
margin-bottom: 32px;
line-height: 1.05;
}
p {
font-size: 20px;
line-height: 1.6;
margin-bottom: 48px;
}
.btn:link,
.btn:visited {
font-size: 20px;
font-weight: 600;
background-color: #e67e22;
color: #fff;
text-decoration: none;
display: inline-block;
padding: 16px 32px;
border-radius: 9px;
}
h2 {
font-size: 44px;
margin-bottom: 48px;
}
section {
padding: 96px 0;
background-color: #f7f7f7;
}
</style>
</head>
<body>
<header>
<nav class="container">
<div>LOGO</div>
<div>NAVIGATION</div>
</nav>
<div class="header-container">
<div class="header-container-inner">
<h1>A healty meal delivered to your door, every single day</h1>
<p>
The smart 365-days-per-year food subscription that will make you eat
healty algain. Tailored to your personal tastes and nutritional
needs
</p>
<a href="#" class="btn">Start eating well</a>
</div>
</div>
</header>
<section>
<div class="container">
<h2>Some random heading</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Atque quas,
minus beatae sapiente debitis voluptatum, laudantium veritatis impedit
corrupti officia recusandae fugit, voluptates iure velit! Ad suscipit
vitae nobis optio. Lorem ipsum dolor sit, amet consectetur adipisicing
elit. Reiciendis sequi quam earum voluptas eum laboriosam at
cupiditate debitis in odio adipisci repudiandae enim ea, sint quos
similique! Debitis, facilis dolore?
</p>
</div>
</section>
<script src="/js/script.js"></script>
<script>
console.log(`hello world`);
</script>
</body>
</html>
2
Answers
You can try removing everything except the bare necessity. Then add each element one by one.
You typed “ instead of ” or "", so it didn’t show the console.log.
About the JS document, check the folder path.