font-synthesis-weight
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2023.
Thuộc tính CSS font-synthesis-weight cho phép bạn chỉ định liệu trình duyệt có được phép tổng hợp kiểu chữ đậm khi kiểu chữ đó không có sẵn trong bộ phông chữ hay không.
Thông thường, thuận tiện hơn khi sử dụng thuộc tính viết tắt font-synthesis để kiểm soát tất cả các giá trị tổng hợp kiểu chữ.
Cú pháp
css
/* Giá trị từ khóa */
font-synthesis-weight: auto;
font-synthesis-weight: none;
/* Giá trị toàn cục */
font-synthesis-weight: inherit;
font-synthesis-weight: initial;
font-synthesis-weight: revert;
font-synthesis-weight: revert-layer;
font-synthesis-weight: unset;
Giá trị
Định nghĩa hình thức
| Initial value | auto |
|---|---|
| Applies to | all elements and text. It also applies to ::first-letter and ::first-line. |
| Inherited | yes |
| Computed value | as specified |
| Animation type | discrete |
Cú pháp hình thức
font-synthesis-weight =
auto |
none
Ví dụ
>Tắt tổng hợp kiểu chữ đậm
Ví dụ này cho thấy cách tắt tổng hợp kiểu chữ đậm bởi trình duyệt trong phông chữ Montserrat.
HTML
html
<p class="english">
This is the default <strong>bold typeface</strong> and
<em>oblique typeface</em>.
</p>
<p class="english no-syn">
The <strong>bold typeface</strong> is turned off here but not the
<em>oblique typeface</em>.
</p>
CSS
css
@import "https://fonts.googleapis.com/css2?family=Montserrat&display=swap";
.english {
font-family: "Montserrat", sans-serif;
}
.no-syn {
font-synthesis-weight: none;
}
Kết quả
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| CSS Fonts Module Level 4> # font-synthesis-weight> |