Skip to content

Remove margin from body in React

I’m new to React and currently in the process of building a website, however I cannot get rid of the margin of the body. My css in inside the index.js component and looks like this:

            <style jsx>{`
         body{
             margin: 0px;
             padding: 0px;
         }
        `}</style>

Answer

You should use global with jsx style

<div>
    <style jsx global>{`
      body {
        margin: 0px;
        padding: 0px;
      }
    `}</style>
  </div>