Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why CSS file is not loaded in the react app

Tags:

html

css

reactjs

I am building a very simple react app. Everything works fine except the CSS file is not loaded, where is the problem?

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link type="text/css" rel="stylesheet" href="/animal_fun_facts/src/styles.css" />
  </head>
  <body>
    <div id="root"></div>
    <script src="/animal_fun_facts/src/index.js"></script>
    <script src="/app.compiled.js"></script>
  </body>
</html>

This is the file structure:

enter image description here

like image 876
Ibo Avatar asked Nov 03 '25 21:11

Ibo


1 Answers

You can use so many ways actually Like css modules,
Since you have created your stylesheet In a separate file, then let's just import it in your application Use the following :

import React from 'react';
import ReactDOM from 'react-dom';
import './animal_fun_facts/src/styles.css';
like image 60
Zakariya ANAYNE Avatar answered Nov 05 '25 14:11

Zakariya ANAYNE