HTML canvas textAlign Property Last Updated : 12 Jun, 2023 Suggest changes Share Like Article Like Report The HTML canvas textAlign Property is used to set or return the current alignment for text content, according to the anchor point. Basically, the text will start at that position and the text will end at that specified position. Syntax: context.textAlign="center | end | left | right | start"; Property Values: start: It has a Default. The text starts at the specified position. end: The text ends at the specified position. left: It is used to set the text-alignment into left. right: It is used to set the text-alignment into right. center: It is used to set the text-alignment into the center. Example: html <!DOCTYPE html> <html> <head> <style> h1, h2 { color: green; } body { text-align: center; } </style> </head> <body> <h1>GeeksForGeeks</h1> <h2>HTML canvas textAlign Property </h2> <canvas id="sudo" width="300" height="200" style="border:3px solid red;"> Your browser does not support the HTML5 canvas tag. </canvas> <script> var c = document.getElementById("sudo"); var ctx = c.getContext("2d"); // Create a blue line in position 170 ctx.strokeStyle = "blue"; ctx.moveTo(170, 20); ctx.lineTo(170, 170); ctx.stroke(); ctx.font = "15px Arial"; // Show the different textAlign values ctx.textAlign = "start"; ctx.fillText("start", 170, 60); ctx.textAlign = "end"; ctx.fillText("end", 170, 80); ctx.textAlign = "left"; ctx.fillText("left", 170, 100); ctx.textAlign = "center"; ctx.fillText("center", 170, 120); ctx.textAlign = "right"; ctx.fillText("right", 170, 140); </script> </body> </html> Output: Supported Browsers: The browsers supported by HTML canvas textAlign Property are listed below: Google Chrome Internet Explorer 9.0 Firefox Apple Safari Opera Create Quiz M manaschhabra2 Follow 0 Article Tags : Web Technologies HTML HTML-Property Explore HTML BasicsHTML Introduction4 min readHTML Editors4 min readHTML Basics7 min readStructure & ElementsHTML Elements4 min readHTML Attributes7 min readHTML Headings3 min readHTML Paragraphs3 min readHTML Text Formatting4 min readHTML Block and Inline Elements3 min readHTML Charsets4 min readListsHTML Lists3 min readHTML Ordered Lists5 min readHTML Unordered Lists4 min readHTML Description Lists3 min readVisuals & MediaHTML Colors11 min readHTML Links Hyperlinks2 min readHTML Images7 min readHTML Favicon4 min readHTML Video4 min readLayouts & DesignsHTML Tables9 min readHTML Iframes4 min readHTML Layout4 min readHTML File Paths3 min readProjects & Advanced TopicsHTML Forms4 min readHTML5 Semantics5 min readHTML URL Encoding4 min readHTML Responsive Web Design11 min readTop 10 Projects For Beginners To Practice HTML and CSS Skills8 min readTutorial ReferencesHTML Tags - A to Z List5 min readHTML Attributes Complete Reference8 min readHTML Global Attributes5 min readHTML5 Complete Reference8 min readHTML5 MathML Complete Reference3 min readHTML DOM Complete Reference15+ min readHTML DOM Audio/Video Complete Reference2 min readSVG Element Complete Reference5 min readSVG Attribute Complete Reference8 min readSVG Property Complete Reference7 min readHTML Canvas Complete Reference4 min read My Profile ${profileImgHtml} My Profile Edit Profile My Courses Join Community Transactions Logout Like