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
  • ชื่อฟอนต์ที่มีช่องว่างต้องอยู่ในเครื่องหมายคำพูด
  • ใช้ Web Fonts (@font-face, Google Fonts) เพื่อความสม่ำเสมอ