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

ย่อหน้าบรรทัดแรกของย่อหน้าใน CSS (text-indent)


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

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

ตัวอย่าง

ลองรันโค้ดต่อไปนี้เพื่อย่อหน้าบรรทัดแรก:

<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, %, ฯลฯ
  • สืบทอดได้