Search code examples
htmlcssfrontendstylesbackground-color

Is there any way I can change background color of the body using external (linked) css?


any other way I can change body color except this one

<body style="background-color: yellow;">

Would prefer to do it externaly with a link to an css file

I tried

<style>
.body
{background-color: green;}

and nothing changed


Solution

  • To perform an action on a tag you have to write the name of the tag alone, when you add a selector class of a point it looks for a class with that name and then for it to work you had to add class="body" like this:

    .body {
       width: 100vw;
       height: 100vh;
       background-color: yellow;
    }
    <body class="body"></body>

    But the correction to what you did is as simple as this without a .:

    body {
       width: 100vw;
       height: 100vh;
       background-color: yellow;
    }
    <body></body>