Skip to content
Advertisement

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>

Advertisement

Answer

You should use global with jsx style

<div>
    <style jsx global>{`
      body {
        margin: 0px;
        padding: 0px;
      }
    `}</style>
  </div>
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement