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

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


คุณสมบัติ font-family

คุณสมบัติ font-family ใช้เปลี่ยนหน้าตาของฟอนต์ ค่าที่เป็นไปได้คือชื่อฟอนต์ใดๆ

<html>
  <head>
  </head>
  <body>
    <p style="font-family:georgia,garamond,serif;">
      This text is rendered in either georgia, garamond, or the default serif font
      depending on which font you have at your system. </p>
  </body>
</html>

แนวทางปฏิบัติที่ดี:

  • ระบุรายการฟอนต์ตามลำดับความชอบ คั่นด้วยจุลภาค
  • จบด้วย generic family: serif, sans-serif, monospace, cursive, fantasy
  • ชื่อฟอนต์ที่มีช่องว่างต้องอยู่ในเครื่องหมายคำพูด
  • ใช้ @font-face หรือ Google Fonts สำหรับฟอนต์เว็บ