To center canvas in HTML 5, include the canvas tag in div tag. Then we can center align the div tag. By doing so, the canvas is also center aligned.
<!DOCTYPE html>. <html> <body> <div style = "text-align:center;"> <canvas style = "background-color:GREEN;">This is my canvas</canvas> </div> </body> </html>