My css include does not work

Hi there,
I’m a (re)beginner to css, and want to try to use it more for design.
I have been through 50 &A, but the questions there are far from my knowledge state - much higher.

I looked into a tutorial and found this:

  <head>
<link href="css_file.css" rel="stylesheet" type="text/css" media="all">

The content of css_file.css is

<style>
body {
  background-color: DarkKhaki 
}
</style>

body is only like it is.
If I put the content directly in the header of HTML, it works, with the link ref I get a white background.
I have done this years ago and it work, right now not.
Can anybody help me please. It is sooo newbie.
Thanks in advance.

The style tags are not CSS they are html tags and do not belong in a css file.

A css file contains only CSS.

body {
  background-color: DarkKhaki 
}

If it still doesn’t work then check the path of the css file.

I tried with no path, as you see, and /css_file.css, which would be ok on the server but not local.
Then I tried /var/www/html/css_file.css, no change.
I also double-checked the name writing.

If you use css_file.css then that means the css file is located in exactly the same place as the html page that calls it (whether local or on the server will make no difference as it is a reative path). Check that the css file exists in the location that you are looking for it?

Did you remember to remove the style tags from the css?

Do you have this page live so we can see what you are actually doing?

Remove the style tags was the clou.
Very very newbie, it seems.
Thank you very much, PaulOB

2 Likes

No worries its a common mistake that we all made at the beginning:)

Everyone has to start somewhere so there’s no shame in not knowing something.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.