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

การใช้งานคุณสมบัติ font ใน CSS


คุณสมบัติ font (Shorthand)

คุณสมบัติ font ใช้เป็น shorthand เพื่อกำหนดคุณสมบัติฟอนต์หลายอย่างพร้อมกัน เช่น font family, size, style เป็นต้น

ตัวอย่าง

ลองรันโค้ดต่อไปนี้เพื่อเรียนรู้การทำงานของคุณสมบัติ font:

<html>
  <head>
  </head>
  <body>
    <p style="font:italic small-caps bold 13px georgia;">
      Applying all the properties on the text at once. </p>
  </body>
</html>

ลำดับค่าที่บังคับ:

font: style variant weight size/line-height family;
  • font-size และ font-family ต้องระบุเสมอ
  • line-height คั่นด้วย slash (/)
  • ค่าที่ละเว้นใช้ค่าเริ่มต้น