Aturan font-face
Aturan @font-face memungkinkan untuk menentukan
font kustom yang sumbernya
disimpan dalam sebuah file. Font ini kemudian dapat
dihubungkan menggunakan properti font-family.
Sintaks
@font-face {
nama font;
sumber untuk mencari font;
}
Contoh
Mari kita cari font di komputer lokal kita:
<body>
This is Montserrat SemiBold.
</body>
@font-face {
font-family: "Montserrat SemiBold";
src: local("Montserrat SemiBold");
}
body {
font-family: "Montserrat SemiBold";
}
#elem {
animation: anim 3s infinite;
border: 1px solid black;
width: 50px;
height: 50px;
}
:
Contoh
Dan sekarang mari tentukan alamat server jarak jauh untuk mencari font:
<body>
This is Bitstream Vera Serif Bold.
</body>
@font-face {
font-family: "Bitstream Vera Serif Bold";
src: url("https://mdn.github.io/css-examples/web-fonts/VeraSeBd.ttf");
}
body {
font-family: "Bitstream Vera Serif Bold", serif;
}
#elem {
animation: anim 3s infinite;
border: 1px solid black;
width: 50px;
height: 50px;
}
: