I'm moved styles.css file to every location in my project and tried to link it in html file. I moved it even in the same folder where html files are, href autocompletion works(line 9 on image), seems styles.css is visible from html file but still it's doesn't applied to the page. Can't find out the reason...
-
You need to add the `type` attribute with the proper value when linking styling sheets. – Ethan Apr 19 '22 at 19:26
-
It doesn't help, besides according to documentation: if rel="stylesheet", the browser will assume the type is "text/css" https://www.w3schools.com/tags/att_link_type.asp – Hasmik Grigoryan Apr 19 '22 at 19:37
-
It is still better to include it and you need a `./` in front of the `style.css` – Ethan Apr 19 '22 at 19:39
-
Steel doesn't work – Hasmik Grigoryan Apr 19 '22 at 19:54
-
Welcome to SO! Please don't upload code, results or data as images for these reasons: https://meta.stackoverflow.com/questions/285551/ – Florian Metzger-Noel Apr 21 '22 at 10:02
2 Answers
As far as your syntax for the style link, it's fine. You could get into a browser console (typically hit F12), then browse the page watching the network tab to make sure the browser finds the css file and loads it.
But I think your problem may be elsewhere. On the code you show, your entire nav (navigation) section is inside the head section of the page (i.e. before /head appears). That's not where it belongs. It should be inside the body section section further down. That's certainly a problem and may be what you think is a css issue.
- sorry about the edit. I didn't know html tags would be eliminated
Edit: As regards the html MIME type instead of the correct CSS MIME type, you might look at this link and check your server configuration and/or .htaccess file to make sure the server hasn't been told to parse css as if it was html: "The stylesheet was not loaded because its MIME type, "text/html" is not "text/css"
Also please show the CSS file, to confirm it actually is css and not actually html.

- 1
- 1
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 20 '22 at 04:05
-
Adding nav section inside body instead of header doesn't help. Also I have an error in network, browser cant find css file. It was searching in localhost:3000/styles.css. I changed css path in html, set it starting from root but again I'm receiving same error in browser network: Refused to apply style from 'http://localhost:3000/src/public/css/styles.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled. – Hasmik Grigoryan Apr 20 '22 at 05:15
-
3 solutions for this type of error from here https://exerror.com/mime-type-text-html-is-not-a-supported-stylesheet-mime-type-and-strict-mime-checking-is-enabled/ also doesn't help – Hasmik Grigoryan Apr 20 '22 at 05:21
-
css file contains only css: .container-fluid { padding-top: 70px; padding-bottom: 70px; } .navbar { padding-top: 15px; padding-bottom: 15px; border: 0; border-radius: 0; margin-bottom: 0; font-size: 12px; letter-spacing: 5px; } .navbar-nav li a:hover { color: #1abc9c; } .footer-padding { padding-bottom: 60px; } .footer { position: absolute; text-align: center; bottom: 0; width: 100%; height: 60px; background-color: #1abc9c; } .footer p { margin-top: 25px; font-size: 12px; color: #fff; } – Hasmik Grigoryan Apr 20 '22 at 19:38
I found the problem. It was in express.js code. I didn't use spatial middleware for static files: app.use(express.static(path.join(__dirname, "public"))); here is the documentation page:https://expressjs.com/en/starter/static-files.html
After adding this in server code, in html href should be the rest of path to css file, in my case:

- 17
- 5