คุณสมบัติตระกูลแบบอักษร CSS ใช้เพื่อตั้งค่าแบบอักษรเฉพาะสำหรับองค์ประกอบที่เลือก ขอแนะนำให้ใช้แบบอักษรที่ปลอดภัยสำหรับเว็บโดยการระบุแบบอักษรเพิ่มเติมเพื่อให้แน่ใจว่าสามารถใช้งานข้ามเบราว์เซอร์ได้
ไวยากรณ์
ไวยากรณ์ของคุณสมบัติตระกูลฟอนต์ CSS มีดังต่อไปนี้ &mins;
Selector {
font-family: /*value*/
} ตัวอย่างต่อไปนี้แสดงคุณสมบัติของ CSS font-family -
ตัวอย่าง
<!DOCTYPE html>
<html>
<head>
<style>
h2 {
background-color: thistle;
font-family: "Magneto", Arial;
}
p {
font-family: "Segoe Print", serif;
font-size: 1.4em;
}
</style>
</head>
<body>
<h2>Learn Fortran</h2>
<p>Fortran, as derived from Formula Translating System, is a general-purpose, imperative programming language. It is used for numeric and scientific computing.</p>
</body>
</html> ผลลัพธ์
สิ่งนี้ให้ผลลัพธ์ต่อไปนี้ -

ตัวอย่าง
<!DOCTYPE html>
<html>
<head>
<style>
th {
font-family: "Franklin Gothic Book", Arial;
border: thin solid blue;
}
td {
font-family: "Lucida Console", serif;
font-size: 1.1em;
box-shadow: inset 0 0 3px black;
}
caption {
font-family: Broadway;
font-size: 24px;
}
</style>
</head>
<body>
<table>
<caption>Demo Table</caption>
<tr>
<th>DEMO 1</th>
<th>DEMO 2</th>
</tr>
<tr>
<td>demo a</td>
<td>demo b</td>
</tr>
<tr>
<td>demo c</td>
<td>demo d</td>
</tr>
</table>
</body>
</html> ผลลัพธ์
สิ่งนี้ให้ผลลัพธ์ต่อไปนี้ -
