Home > Back-end >  Can't link CSS to HTML in Github Pages
Can't link CSS to HTML in Github Pages

Time:12-19

Im new to Github, when i open the website my html is showing without my css. Here is my html code:

<!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>NFT-Card</title>
    <link rel="stylesheet" href="/nft.css">
    <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600&display=swap" rel="stylesheet">
</head>
<body>
    <div>
        <img id="mainImage" src="/NFT-Card/images/image-equilibrium.jpg" alt="">
        <h2>Equilibrium #3429</h2>
        <p id="paragraphExp">Our Equilibrium collection promotes balance and calm</p>
        <img id="ethIcon" src="/NFT-Card/images/icon-ethereum.svg" alt="">
        <p id="price">0.041ETH</p>
        <img id="clockImage" src="/NFT-Card/images/icon-clock.svg" alt="">
        <p id="clockText">3 days left</p>
        <hr>
        <img id="avatar" src="/NFT-Card/images/image-avatar.png" alt="">
        <p id="author">Creation of <b id="boldEl">Jules Wyvern</b></p>
    </div>
</body>
</html>

Here is my Github repository: https://github.com/Tonka12/tonka12.github.io

CodePudding user response:

You can try to add a . befaure the / :

<link rel="stylesheet" href="./nft.css">

CodePudding user response:

the css file and your html file are in the same folder. so the href should be:

<link rel="stylesheet" href="nft.css">
  • Related