Using Visual Studio Code to show HTML and CSS

Hi, I have read and followed the steps of this article (https://www.codecademy.com/articles/visual-studio-code), which illustrates how to download and set up HTML files on this new code editor.

However, while my HTML code works when I run it in a web browser, I can’t seem to apply the CSS to the HTML code in the browser even though I used the following link


<link href="index.css" type="text/css" rel="stylesheet">
    <title class="title">

Yes, I am running into a similar problem. Been scouring the web for days looking for a solution.

1 Like

What is your full code and what is your file structure? There are several things that could be stopping it from linking so I’ll need to see a bunch of it before being able to tell the problem.

Users\Sami\Desktop\Projects\Hello World Inside “Hello World” I have two files, one that is showing the web page HTML code “rendered” (if that’s the right word), the other showing the raw CSS code by itself.

The following is my full HTML followed by my CSS code:

HTML:


  <head>

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

    <title class="title"> Hello World</title> 

  </head>

  <body> 

    <h1>Hello World</h1> 

  </body>

</html>


**CSS code:**

h1 {

color: white;

background-color: green;

}```

<title></title> is not a BODY element, but a HEAD element, only. It cannot be styled.

1 Like

As I typed this, I realized that I made a mistake in my code and now that I fixed it, my code seems to work fine. However, user: tag8815082103 (above) might need some help. Thanks all.

We realized that at the same time! Thank you for spotting it. I then styled h1 and ran the code and it worked.

1 Like