ในการสร้างกราฟิกด้วยสคริปต์ ให้ใช้แท็ก
ต่อไปนี้เป็นแอตทริบิวต์ของแท็ก
| แอตทริบิวต์ | ค่า | คำอธิบาย |
|---|---|---|
height | pixels | ระบุความสูงของผ้าใบ |
ความกว้าง | pixels | ระบุความกว้างของผ้าใบ |
ตัวอย่าง
คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อใช้แท็ก
<!DOCTYPE html>
<html>
<head>
<title>HTML Canvas Tag</title>
</head>
<body>
<canvas id = "newCanvas">Your browser does not support canvas tag.</canvas>
<script>
var c = document.getElementById('newCanvas');
var ctx = c.getContext('2d');
ctx.fillStyle = '#00AEEF';
ctx.fillRect(0,0,180,50);
</script>
</body>
</html>