Kiểu phông chữ
Thí dụ
Đặt phông chữ cho một phần tử thành "nghiêng":
document.getElementById("demo").style.fontStyle = "italic";
Định nghĩa và Cách sử dụng
Thuộc tính fontStyle đặt hoặc trả về kiểu phông chữ là bình thường, nghiêng hay xiên.
Hỗ trợ trình duyệt
Property | |||||
---|---|---|---|---|---|
fontStyle | Yes | Yes | Yes | Yes | Yes |
Cú pháp
Trả về thuộc tính fontStyle:
object.style.fontStyle
Đặt thuộc tính fontStyle:
object.style.fontStyle = "normal|italic|oblique|initial|inherit"
Giá trị tài sản
Value | Description |
---|---|
normal | Font is normal. This is default |
italic | Font is in italic |
oblique | Font is in oblique |
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: | thông thường |
---|---|
Giá trị trả lại: | Một chuỗi, đại diện cho kiểu phông chữ của văn bản trong phần tử |
Phiên bản CSS | CSS1 |
Các ví dụ khác
Thí dụ
Một minh chứng về các giá trị có thể có:
var listValue = selectTag.options[selectTag.selectedIndex].text;
document.getElementById("demo").style.fontStyle = listValue;
Thí dụ
Trả lại kiểu phông chữ của một phần tử:
alert(document.getElementById("demo").style.fontStyle);
Các trang liên quan
Hướng dẫn CSS: Phông chữ CSS
Tham chiếu CSS: thuộc tính font-style
Tham chiếu DOM HTML: thuộc tính phông chữ
❮ Đối tượng phong cách