JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

JavaScript

//grid width and height
    var bw = window.innerWidth / 2; //size before padding
    var bh = window.innerHeight / 1.3; //size before padding
    //padding around grid, h and w
    var pW = 30;
    var pH = 2;
    var lLimit = 0; //limit is 9 for both height and width

    //size of canvas - it will consist the padding around the grid from all sides + the grid itself. it's a total sum
    var cw = bw + pW;
    var ch = bh + pH;
 
    var canvas = $('<canvas/>').attr({width: cw, height: ch}).appendTo('body');

    var context = canvas.get(0).getContext("2d");

    function drawBoard(){ 
   
         for (var x = 0; lLimit <= 8; x += bw / 8) { //handling the height grid 
            context.moveTo(x, 0);
            context.lineTo(x, bh);
            lLimit++;
        }

        for (var x = 0; lLimit <= 17; x += bh / 8) { //handling the width grid
            context.moveTo(0, x); //begin the line at this cord, which is beyond the padding
            context.lineTo(bw, x); //end the line at this cord
            lLimit++;
        }
        //context.lineWidth = 0.5; what should I put here?
        context.strokeStyle = "black";
        context.stroke();
    }

    drawBoard();