0

I am working in Visual Studio Code, with extension "open in browser" so that I can preview my code in Google Chrome. I have my basic HTML done, and I am trying to link it to an external CSS file. However, the background color I have set in the CSS file is not showing up.

I have looked up solutions and can't see any issue with my code.

HTML

<head>
    <title>Site</title>
    <link rel = "Website Style" type = "text/css" href = "ResumeStyle.css" >
</head>

CSS

body{
background-color: darkgray;
}

This should change the background to dark gray, but it remains white. I'm not sure if it's an issue with my code or if it has to do with the Chrome extension. Sorry if its a basic question I'm just not seeing the issue.

Matt
  • 15
  • 3

4 Answers4

2

Change rel="Website Style" to rel="stylesheet". Also double check the path to your CSS is correct.

You can read about the different rel attributes here: https://www.w3schools.com/tags/att_link_rel.asp

HoldOffHunger
  • 18,769
  • 10
  • 104
  • 133
jjsecord
  • 114
  • 5
0

It's likely that your issue is that you are modifying a CSS property for 'body', but you aren't using 'body' in your html file. Check out this simple example from W3Schools Here

This is what I'm thinking you might need, just adding the body tag.

<head>
    <title>Site</title>
    <link rel = "Website Style" type = "text/css" href = "ResumeStyle.css" >
</head>
<body>
</body>```
Reid Svntn
  • 116
  • 1
  • 3
0

Recheck the spelling of file, even the capitalize letter can cause this issue.

HoldOffHunger
  • 18,769
  • 10
  • 104
  • 133
Wania Kanwal
  • 77
  • 1
  • 8
0

You need to check the path: if the css' file and the html's file are on the same folder.

If they are, then:

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

If the stylesheet is on another folder then you need to change the href.

Also check if the ResumeStyle name is correct, capital letters matters. And check if you really have a body in your html.

If any of these answer works for you, please leave a vote.

There is a great answer about that here.

Iandra Bedin
  • 116
  • 1
  • 1
  • 6