Search code examples
htmlcssreactjsweb-applications

Background color of the react application is not applied correclty


I trying to add the background color for my react app. background color is not applied to the whole screen. Here is the code for the App.js file

import React from "react";
import "./App.css";

function App() {
  return (
    <body className="App">
      <div>
        <h1>Hello world</h1>
      </div>
    </body>
  );
}

export default App;

and the source code of the App.css file is here

.App {
  background-color: #efeff6;
  height: 100%;
  width: 100%;
  position: fixed;
}

The result of this here and you can see some white space in left and the right sides. enter image description here

Can I know that is the mistake I have done?


Solution

  • in file index.css change this.

    body {
      margin: 0;
    }