1

enter image description here

This is how my folder looks like.

<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible">
        <link rel="stylesheet" href="../src/App.css">
        <title>Document</title>
    </head>

    <body>
        <div id="practice"></div>
        <div id="farm"></div>

    </body>
</html>

And this is the code, but still React won't track the path from the HTML. CSS file won't be loaded even the path is correct.

enter image description here

I can open the file by clicking CTRL + LMB in VSC like a GIF above. For testing, I changed the path as ./src/App.css then VSC couldn't open it because the path is wrong.

Why it keeps happening and are there any ways to fix this problem?

Thanks to listen.

1 Answer 1

1

You should import your css in app.js or any js file on your src folder instead calling it on public folder. You should see it on the app.js since I think you using create-react-app so you should see some example on that js file. You doing it wrong.

If you really want to do that did you try to add %PUBLIC_URL%/src/App.css ?

import '../src/App.css'
Sign up to request clarification or add additional context in comments.

1 Comment

Oh I removed %PUBLIC_URL% something in the HTML for practice. Maybe that could be the reason. Thank you for answering.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.