1

The following base.html code is not implementing the gradient background from the css file that is in the same folder.

base.html:

<!doctype html>
<html lang="en">
  <head>
    <link rel="stylesheet" text="text/css" href="templates/css/style.css">
  </head>

<body>
<h1>hi</h1>
</body>
</html>

style.css:

body {
background: linear-gradient(to bottom, #faaca8, #ddd6f3);
background-repeat: no-repeat;
background-size: cover;
width: 100%;
height: 100%;

}

Elaina Tiller
  • 11
  • 1
  • 4
  • 2
    If it's in the same folder, why does the href is not set to ./style.css ? – Kostas Minaidis Dec 05 '19 at 01:47
  • 1
    you mean it's not working at all? or just not covering the entire page like you want it to? – Jeremy Dec 05 '19 at 01:48
  • 1
    Change your `link` to `` - you're currently trying to go into the folder /templates from your current position, which clearly doesn't make sense as the css is in the current folder. – EGC Dec 05 '19 at 01:48
  • check you css path. –  Aug 17 '21 at 06:04

3 Answers3

2

If this is not working, the problem is going to be the fact that you are referring to a different directory than you are wanting for the style.css folder. If it's in the same folder, please change the href in the link to href="style.css".

This is assuming you have one folder with the base.html and in the SAME folder, there is also the style.css stylesheet .

If it's based on the root directory, you would use /style.css , or on the folder before, ../foldername/style.css. For more, read here.

Jeremy
  • 1,038
  • 11
  • 34
0

Put the css codes inside the body tag or you can do it like this

   body {
    background: linear-gradient(to bottom, #faaca8, #ddd6f3);
    background-repeat: no-repeat;
    background-size: cover;
    width: 100%;
    height: 100%;
    <!doctype html>
    <html lang="en">
      <head>
    <link rel="stylesheet" type="text/css" href="style.css">  </head>
    
    <body>
    <h1>hi</h1>
    
    
   
    </body>
    </html>
Moo
  • 25
  • 8
0

text="text/css" should read type="text/css"

user328414
  • 1,230
  • 1
  • 9
  • 15