I'm embarking on a journey to learn HTML, CSS, and JavaScript by creating a basic webpage. Despite linking my CSS file in the HTML document, I am facing an issue where none of the styles are being applied.
I am currently running this project locally using Node.js.
HTML:
<!DOCTYPE html>
<html>
<head>
<link href='./css/styles.css' type='text/css' rel='stylesheet'>
</head>
My server.js file:
var http = require('http');
var fs = require('fs');
const PORT=8080;
fs.readFile('./index.html', function (err, html) {
if (err) throw err;
http.createServer(function(request, response) {
response.writeHeader(200, {"Content-Type": "text/html"});
response.write(html);
response.end();
}).listen(PORT);
});
Additionally, I encountered the following error:
"Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:8080/css/styles.css"."
Should I include another content-type declaration for "text/css" in my server.js file?
Document tree: