หากต้องการตั้งค่าการเยื้อง ให้ใช้คุณสมบัติ textIndent
ตัวอย่าง
คุณสามารถลองรันโค้ดต่อไปนี้เพื่อคืนค่าการเยื้องของบรรทัดแรกของข้อความด้วย JavaScript −
<!DOCTYPE html> <html> <body> <div id = "myText"> This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. </div> <br> <button onclick = "display()">Set Text Indent</button> <script> function display() { document.getElementById("myText").style.textIndent = "50px"; } </script> </body> </html>