Por que o Chrome não apresentar o meu @font-face?

0

Pergunta

Eu estou carregando um Hello World arquivo html no Chrome 95, com uma declaração de @font-face carregado a partir do Google fontes. A fonte é corretamente carga, que eu possa verificar na guia Rede, mas por algum motivo o meu div é a prestação de como os Tempos.

O que estou fazendo de errado?

<html>
<div style='font-family:OpenSans-Regular;'>
    Hello World!
</div>
</html>
<style>
    @font-face {
      font-family: OpenSans-Regular;
      font-style: normal;
      font-weight: 400;
      font-stretch: 100%;
      font-display: swap;
      src: url(https://fonts.gstatic.com/s/opensans/v27/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSKmu0SC55K5gw.woff2) format('woff2');
    }
</style>
css font-face google-chrome html
2021-11-23 02:28:37
1

Melhor resposta

1

A partir do Google tipos de letra do documento, você deverá usar <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Font+Name"> em vez de escrevê-los diretamente.

O seu <style> o elemento está no lugar errado, não há <body> elemento do HTML.

<html>
    <head>
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans">

        <style>
            * {
                font-family: "Open Sans";
            }
        </style>
    </head>
    <body>
        <div style='font-family:Open Sans'>
            Hello World!
        </div>
    </body>
</html>
2021-11-23 03:23:17

Em outros idiomas

Esta página está em outros idiomas

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................