curriculum/challenges/english/blocks/review-css-typography/671a9528fc4f1487cf265444.md
font-family Propertyfont-family: Arial, Lato;
Definition: These fonts are a subset of fonts that are very likely to be installed on a computer or device. When the browser has to render a font, it tries to find the font file on the user's system. But if the font is not found, it will usually fall back to a default system font.
Web Safe Fonts:
@font-face At-rule@font-face: This allows you to define a custom font by specifying the font file, format, and other important properties, like weight and style. For the @font-face at-rule to be valid, you also need to specify the src property. This property contains references to the font resources.@font-face {
font-family: "MyCustomFont";
src: url("path/to/font.woff2"),
url("path/to/font.woff"),
url("path/to/font.otf");
}
collection, embedded-opentype, opentype, svg, truetype, woff, and woff2.@font-face {
font-family: "MyCustomFont";
src: url("path/to/font.woff2") format("woff2"),
url("path/to/font.otf") format("opentype"),
url("path/to/font.woff") format("woff");
}
woff and woff2: woff stands for "Web Open Font Format." It's a widely used font format developed by Mozilla in collaboration with Type Supply, LettError, and other organizations. The difference between woff and woff2 is the algorithm used to compress the data.tech(): This is used to specify the technology of the font resource. This is optional.@font-face {
font-family: "MyCustomFont";
src: url("path/to/font.woff2") format("woff2"),
url("path/to/font.otf") format("opentype") tech(color-COLRv1),
url("path/to/font.woff") format("woff");
}
link element or @import statement inside your CSS.Here is an example using the link element:
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel="stylesheet">
.roboto-thin {
font-family: "Roboto", sans-serif;
font-weight: 100;
font-style: normal;
}
Here is an example using the @import statement:
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap');
text-shadow Property:::interactive_editor
<link rel="stylesheet" href="styles.css">
<p>Typography Shadow</p>
p {
text-shadow: 3px 2px;
}
:::
:::interactive_editor
<link rel="stylesheet" href="styles.css">
<p>Colored Shadow</p>
p {
text-shadow: 3px 2px #00ffc3;
}
:::
:::interactive_editor
<link rel="stylesheet" href="styles.css">
<p>Blurred Shadow</p>
p {
text-shadow: 3px 2px 3px #00ffc3;
}
:::
:::interactive_editor
<link rel="stylesheet" href="styles.css">
<p>Multiple Shadows</p>
p {
text-shadow:
3px 2px 3px #00ffc3,
-3px -2px 3px #0077ff,
5px 4px 3px #dee7e5;
}
:::
Review the CSS Typography topics and concepts.