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ị

auto

Cho biết rằng trình duyệt có thể tổng hợp kiểu chữ đậm còn thiếu nếu cần.

none

Cho biết rằng việc tổng hợp kiểu chữ đậm còn thiếu bởi trình duyệt không được phép.

Định nghĩa hình thức

Initial valueauto
Applies toall elements and text. It also applies to ::first-letter and ::first-line.
Inheritedyes
Computed valueas specified
Animation typediscrete

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

Specification
CSS Fonts Module Level 4
# font-synthesis-weight

Khả năng tương thích trình duyệt

Xem thêm