คุณสมบัติ CSS font-weight ใช้เพื่อกำหนดตัวหนาของอักขระข้อความขององค์ประกอบ
ไวยากรณ์
ไวยากรณ์ของคุณสมบัติ CSS font-weight มีดังนี้ -
Selector {
font-weight: /*value*/
} ตัวอย่าง
ตัวอย่างต่อไปนี้แสดงคุณสมบัติ font-weight -
<!DOCTYPE html>
<html>
<head>
<style>
div {
margin: 3px;
font-family: "Ink Free";
width: 30%;
font-size: 24px;
}
#one {
font-weight: normal;
border-bottom: 2px dashed greenyellow;
}
#two {
font-family: "Kristen ITC";
font-weight: bolder;
border-bottom: 2px dashed cornflowerblue;
}
#three {
font-weight: bold;
border-bottom: 2px dashed chocolate;
}
</style>
</head>
<body>
<div id="one">First Demo Text</div>
<div id="two">Another Demo Text</div>
<div id="three">Last Demo Text</div>
</body>
</html> ผลลัพธ์
สิ่งนี้ให้ผลลัพธ์ต่อไปนี้ -

ตัวอย่าง
<!DOCTYPE html>
<html>
<head>
<style>
[class|=lis] {
font-style: italic;
font-weight: bold;
}
li[class|="lis-ul"] {
background-color: cadetblue;
font-family: Helvetica;
font-weight: 100;
color: gainsboro;
width: 20%;
}
</style>
</head>
<body>
<h2>Tutorials</h2>
<ol>
<li><p>C#</li>
<li class="lis-ul-2">DBMS</li>
<li class="lis-3">OS</li>
<li>Java</li>
<ul>
<li class="lis-ul-one">Core Java</li>
<li class="lis">Advance Java</li>
</ul>
</ol>
</body>
</html> ผลลัพธ์
สิ่งนี้ให้ผลลัพธ์ต่อไปนี้ -
