Bug when making a new p5.js workspace

I have a bug whenever I make a p5.js workspace. When I run the code, there’s a 5-10px border of white space around the canvas and I don’t know how to fix it. It also happens when I open the page in a new browser by itself.


Hey! Can you share the HTML and CSS files please? There’s likely margin around the body/canvas that could be removed :slight_smile:

The HTML code is:

<!DOCTYPE html>
  <title>P5.js Testing</title>
  <meta name="viewport" content="width=device-width,initial-scale=1" >
  <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/addons/p5.sound.min.js"></script>
  <link href="style.css" rel="stylesheet">

  <script src="sketch.js"></script>

There’s nothing in the CSS file. I don’t know what’d be making a margin, I deleted the CSS code when I created the workspace to make sure nothing interfered with the p5js.

Try adding:

body {
  margin: 0;

As a rule within the CSS file, that would hopefully remove it :slight_smile:

Hey, sorry I took so long to get back to you.
I tried that and it worked for the sides and top, except there was still some on the bottom for some reason.

However, when I made a new workspace, that one didn’t have any, so I guess I can just delete the old one and use the new one now.
Thanks for your help!