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

กำหนดน้ำหนักฟอนต์ด้วย CSS (font-weight)


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

คุณสมบัติ font-weight ใช้เพิ่มหรือลดความหนาของฟอนต์ ระบุได้ว่าฟอนต์จะหนาแน่เพียงไหน ค่าที่เป็นไปได้: normal, bold, bolder, lighter, 100-900 (ทุก 100)

<html>
  <head>
  </head>
  <body>
    <p style="font-weight:bold;">This font is bold.</p>
    <p style="font-weight:bolder;">This font is bolder.</p>
    <p style="font-weight:500;">This font is 500 weight.</p>
  </body>
</html>

ค่าที่ใช้ได้:

  • Keyword: normal (400), bold (700), bolder, lighter
  • ตัวเลข: 100 (Thin) ถึง 900 (Black/Heavy) ทุก 100

หมายเหตุ: ฟอนต์ต้องรองรับน้ำหนักที่ระบุ มิฉะนั้นเบราว์เซอร์จะใช้ค่าที่ใกล้ที่สุด