Joshua
Joshua

Reputation: 1055

styles.css is not being applied to only one page in react and node.js app

So i have a website built in react and uses node.js, all pages load correctly but one, it does not load the css correctly, i am not sure why. Another interesting thing is that it is not present in the developer tools either, Firefox and Google.

The below in in my .html file

<link rel="stylesheet" type="text/css" href="styles.css" />

when i load my project on localhost, i get this error.

The stylesheet http://localhost:3001/product/styles.css was not loaded because its MIME type, "text/html", is not "text/css".

If anyone can help that would be great as I can't seem to figure out why. Note: i removed comments from the beginning of my css file.

Upvotes: 1

Views: 1503

Answers (2)

Felipe Candal Campos
Felipe Candal Campos

Reputation: 174

It's not necessary as pointed out by StepUp. Therefore, you should probably use them with JavaScript import statement.

Where is your css located? The file name is correct?

Upvotes: 0

StepUp
StepUp

Reputation: 38199

It is necessary to include styles in ReactJS through import statement:

import './css/component.css';

See a complete example here

And also there is a React docs "Adding a Stylesheet"

Upvotes: 1

Related Questions