How to center canvas in HTML5?

HTMLWeb DevelopmentFront End Technology

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.

Example

<!DOCTYPE html>.
<html>
   <body>
      <div style = "text-align:center;">
         <canvas style = "background-color:GREEN;">This is my canvas</canvas>
      </div>
   </body>
</html>
raja
Published on 20-Mar-2018 10:30:06
Advertisements