2021年1月29日星期五

How to Link Css Externally In Virtual Studio Code

i am using VS code to make a website and it says Hello World! I am trying to use <link rel='stylesheet> type='text/css href='style.css. but it is not linking correctly. in the css file i have h1{color:red;} but the h1 is not red. if i put the style tag inside the html file it does work. how would i link the css code externally? html:

<!DOCTYPE html>  <html>      <head>          <title>Testing VSC</title>          <link rel='stylesheet' type='text/css' href='style.css'>          <style>              h1{                  color:red              }          </style>      </head>      <body>          <h1 id='test'>HI!</h1>      </body>  </html>  
//node.js server:   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);  });  

how could i link the css file properly?

https://stackoverflow.com/questions/65960130/how-to-link-css-externally-in-virtual-studio-code January 30, 2021 at 02:48AM

没有评论:

发表评论