const canvas = document.getElementById("canvas"); const ctx = canvas.getContext("2d"); // Set canvas size canvas.width = 500; // Adjust as needed canvas.height = 200; // Adjust as needed // Set background color and text properties ctx.fillStyle = "#ffffff"; // Background color ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.fillStyle = "#000000"; // Text color ctx.font = "30px Arial"; // Font size and family // Set text alignment to center horizontally and top vertically ctx.textAlign = "center"; // Horizontally center the text ctx.textBaseline = "top"; // Align the text to the top of the canvas // Draw the text at the top-center ctx.fillText("Your Text Here", canvas.width / 2, 20); // Change "Your Text Here" to your desired text