Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

ย่อหน้าข้อความย่อหน้าด้วย CSS (text-indent)


คุณสมบัติ text-indent

คุณสมบัติ text-indent ใช้ย่อหน้าข้อความของย่อหน้า ค่าที่เป็นไปได้: เปอร์เซ็นต์ หรือตัวเลขระบุระยะย่อ

ตัวอย่าง

ลองรันโค้ดต่อไปนี้เพื่อนำ text-indent ไปใช้ใน CSS:

<html>
  <head>
  </head>
  <body>
    <p style="text-indent:2cm;">
      This text will have first line indented by 2cm and this line will remain at
      its actual position this is done by CSS text-indent property. </p>
  </body>
</html>

รายละเอียด:

  • เฉพาะบรรทัดแรกของย่อหน้าที่จะถูกย่อ
  • ค่าลบได้ (hanging indent)
  • หน่วย: px, em, rem, cm, %, ฯลฯ
  • สืบทอดได้