In canvas, when writing width and height on canvas, it is the actual artboard size of canvas. By default, width is 300px and height is 150px.
When writing css style in style, widht and height are the actual display size.
Now use canvas to draw a diagonal line as an example: