Thuộc tính kiểu phông chữWeight
Ví dụ
Đặt trọng lượng phông chữ cho một phần tử thành "900":
document.getElementById("demo").style.fontWeight = "900";
Hãy tự mình thử »Sự miêu tả
Thuộc tính fontWeight đặt hoặc trả về độ dày hoặc mỏng của ký tự trong văn bản sẽ được hiển thị.
Hỗ trợ trình duyệt
Property | |||||
---|---|---|---|---|---|
fontWeight | Yes | Yes | Yes | Yes | Yes |
Cú pháp
Trả về thuộc tính fontWeight:
object .style.fontWeight
Đặt thuộc tính fontWeight:
object .style.fontWeight = "normal|lighter|bold|bolder| value |initial|inherit"
Giá trị tài sản
Value | Description |
---|---|
normal | Font is normal. This is default |
lighter | Font is lighter |
bold | Font is bold |
bolder | Font is bolder |
100 200 300 400 500 600 700 800 900 |
Defines from light to bold characters. 400 is the same as normal, and 700 is the same as bold |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Chi tiết kỹ thuật
Giá trị mặc định: | Bình thường |
---|---|
Giá trị trả về: | Một chuỗi, thể hiện độ đậm của phông chữ |
Phiên bản CSS | CSS1 |
Thêm ví dụ
Ví dụ
Một minh chứng về các giá trị có thể:
var listValue = selectTag.options[selectTag.selectedIndex].text;
document.getElementById("demo").style.fontWeight = listValue;
Hãy tự mình thử »Ví dụ
Trả về độ đậm phông chữ của một phần tử:
alert(document.getElementById("demo").style.fontWeight);
Hãy tự mình thử »Trang liên quan
Hướng dẫn CSS: Phông chữ CSS
Tham chiếu CSS: thuộc tính font-weight
Tham chiếu DOM HTML: thuộc tính phông chữ