2021-06-15 16:21:20 +02:00
---
id: bad87fee1348bd9aedf08808
2021-07-21 20:53:20 +05:30
title: Especificar soluções para quando uma tipografia não estiver disponível
2021-06-15 16:21:20 +02:00
challengeType: 0
videoUrl: 'https://scrimba.com/c/cpVKBfQ'
forumTopicId: 18304
dashedName: specify-how-fonts-should-degrade
---
# --description--
2021-06-28 20:01:36 +05:30
Por padrão, existem várias tipografias disponíveis em todos os navegadores. As tipografias padrão são: `monospace` , `serif` e `sans-serif` .
2021-06-15 16:21:20 +02:00
2021-06-28 20:01:36 +05:30
Quando uma tipografia não estiver disponível, você pode dizer ao navegador para usar outra tipografia.
2021-06-15 16:21:20 +02:00
2021-06-28 20:01:36 +05:30
Por exemplo, se um elemento usa a tipografia `Helvetica` , mas você quer que ele use `sans-serif` quando a `Helvetica` não estiver disponível, você pode fazer assim:
2021-06-15 16:21:20 +02:00
```css
p {
font-family: Helvetica, sans-serif;
}
```
2021-06-28 20:01:36 +05:30
O nome dessas tipografias não diferenciam maiúsculas de minúsculas. Além disso, eles não precisam de aspas porque são palavras-chave do CSS.
2021-06-15 16:21:20 +02:00
# --instructions--
2021-06-28 20:01:36 +05:30
Para começar, aplique a tipografia `monospace` ao elemento `h2` , fazendo com que o elemento tenha duas tipografias - `Lobster` e `monospace` .
2021-06-15 16:21:20 +02:00
2021-06-28 20:01:36 +05:30
No desafio anterior, você importou a tipografia `Lobster` usando a tag `link` . Comente a importação da tipografia `Lobster` (usando os comentários HTML que você aprendeu antes) do Google Fonts para que ela não esteja mais disponível. Note como o elemento `h2` muda para a tipografia `monospace` .
2021-06-15 16:21:20 +02:00
2021-06-28 20:01:36 +05:30
**Observação:** se você tiver a tipografia `Lobster` instalada em seu computador, não verá a mudança porque seu navegador é capaz de encontrá-la.
2021-06-15 16:21:20 +02:00
# --hints--
2021-06-28 20:01:36 +05:30
O elemento h2 deve usar a tipografia `Lobster` .
2021-06-15 16:21:20 +02:00
```js
assert(
$('h2')
.css('font-family')
.match(/^"?lobster/i)
);
```
2021-06-28 20:01:36 +05:30
O elemento h2 deve mudar para a tipografia `monospace` quando `Lobster` não estiver disponível.
2021-06-15 16:21:20 +02:00
```js
assert(
/\s*h2\s*\{\s*font-family\s*\:\s*(\'|"|)Lobster\1\s*,\s*monospace\s*;?\s*\}/gi.test(
code
)
);
```
2021-06-28 20:01:36 +05:30
Você deve comentar a importação da tipografia `Lobster` usando `<!--` .
2021-06-15 16:21:20 +02:00
```js
assert(new RegExp('<!-- [^fc]', 'gi').test(code));
```
2021-06-28 20:01:36 +05:30
Você deve fechar o comentário usando `-->` .
2021-06-15 16:21:20 +02:00
```js
assert(new RegExp('[^fc]-->', 'gi').test(code));
```
# --seed--
## --seed-contents--
```html
< link href = "https://fonts.googleapis.com/css?family=Lobster" rel = "stylesheet" type = "text/css" >
< style >
.red-text {
color: red;
}
h2 {
font-family: Lobster;
}
p {
font-size: 16px;
font-family: monospace;
}
< / style >
< h2 class = "red-text" > CatPhotoApp< / h2 >
< main >
< p class = "red-text" > Click here to view more < a href = "#" > cat photos< / a > .< / p >
2021-09-22 08:34:59 -07:00
< a href = "#" > < img src = "https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt = "A cute orange cat lying on its back." > < / a >
2021-06-15 16:21:20 +02:00
< div >
< p > Things cats love:< / p >
< ul >
< li > cat nip< / li >
< li > laser pointers< / li >
< li > lasagna< / li >
< / ul >
< p > Top 3 things cats hate:< / p >
< ol >
< li > flea treatment< / li >
< li > thunder< / li >
< li > other cats< / li >
< / ol >
< / div >
< form action = "https://freecatphotoapp.com/submit-cat-photo" >
< label > < input type = "radio" name = "indoor-outdoor" checked > Indoor< / label >
< label > < input type = "radio" name = "indoor-outdoor" > Outdoor< / label > < br >
< label > < input type = "checkbox" name = "personality" checked > Loving< / label >
< label > < input type = "checkbox" name = "personality" > Lazy< / label >
< label > < input type = "checkbox" name = "personality" > Energetic< / label > < br >
< input type = "text" placeholder = "cat photo URL" required >
< button type = "submit" > Submit< / button >
< / form >
< / main >
```
# --solutions--
```html
<!-- <link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css"> -->
< style >
.red-text {
color: red;
}
h2 {
font-family: Lobster, monospace;
}
p {
font-size: 16px;
font-family: monospace;
}
< / style >
< h2 class = "red-text" > CatPhotoApp< / h2 >
< main >
< p class = "red-text" > Click here to view more < a href = "#" > cat photos< / a > .< / p >
2021-06-28 20:01:36 +05:30
2021-09-22 08:34:59 -07:00
< a href = "#" > < img src = "https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt = "A cute orange cat lying on its back." > < / a >
2021-06-28 20:01:36 +05:30
2021-06-15 16:21:20 +02:00
< div >
< p > Things cats love:< / p >
< ul >
< li > cat nip< / li >
< li > laser pointers< / li >
< li > lasagna< / li >
< / ul >
< p > Top 3 things cats hate:< / p >
< ol >
< li > flea treatment< / li >
< li > thunder< / li >
< li > other cats< / li >
< / ol >
< / div >
2021-06-28 20:01:36 +05:30
2021-06-15 16:21:20 +02:00
< form action = "https://freecatphotoapp.com/submit-cat-photo" >
< label > < input type = "radio" name = "indoor-outdoor" checked > Indoor< / label >
< label > < input type = "radio" name = "indoor-outdoor" > Outdoor< / label > < br >
< label > < input type = "checkbox" name = "personality" checked > Loving< / label >
< label > < input type = "checkbox" name = "personality" > Lazy< / label >
< label > < input type = "checkbox" name = "personality" > Energetic< / label > < br >
< input type = "text" placeholder = "cat photo URL" required >
< button type = "submit" > Submit< / button >
< / form >
< / main >
```