Search code examples
cssexternal

External CSS don't work


I have an external css file, linked in to the html. If i apply style for example a div class it Works, but when i apply style for html, body etc. it doesn't work. Why is that?

This is the CSS code:

 html {
        background: url(img/bc.jpg) no-repeat center center fixed;
        background-size: cover;

        -webkit-background-size: cover;
        -moz-background-size: cover;
        -o-background-size: cover;
    }

This code only work, when i put a style tag into the html file.

And this is the HTML:

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

    <body>

    </body>
</html>

Solution

  • enter image description here
    check the image if you have have a html file and folder css which holds the css file like the given image then you can add the css to html like the given link tag.

    < link rel="stylesheet" href="css/base.css">

    now you can write whatever css you want under the css/base.css file and you have to use the url directory property like

    url("../image/image.png")

    whick says that one level up and find the image directory and add image.png to this html document