I decided to go deeper and I came to this answer:
To define what type of font to use in any code snippet HTML
, through CSS
, we must use the font-family
property with the name of the font you want.
Thus, the syntax for defining and using a source in CSS
is:
font-family: "Nome da Fonte";
You can build the entire design of your site based on a source, and your reader simply will not see the source because it is not installed or has not come in the operating system of your computer.
And now, what can be done to prevent this?
One of the solutions to this problem is to give a list of sources as value, for attribute "font-family"
, separated by commas. If the browser does not support the first source, it tries the next source.
There are two types of font family names:
• Family-name - The name of a family source, such as "times", "courier", "arial", etc.
Generic-family - The name of a generic family, such as "serif", "sans-serif", "cursive", "fantasy"
The CSS
will try to style with the first declared font, if it exists on the player's computer, it will be displayed, and if it is not present, the CSS
style will try to be done with the second font.
And finally, if you do not have any of the sources on the user's computer, browser
will show a default system font.
Start with the desired font and always end up with a generic family, to allow the browser to choose a similar font in the generic family if no other font is available.
Another widely used solution is: @font-face
, you must first define a name for the source (for example, myfont), and then point to the source file. See:
@font-face {
font-family:'minhafonte';
src:url("../fonts/bubblegum-sans-regular.otf");
}
div {
font-family:minhafonte;
}
And finally we can use one of the simplest and most guaranteed forms that are Google Web Fonts sources, since they are web
and all tested and approved by google platform.
For this you must specify the source path provided in google fonts
, shortly after the source is installed and ready to use, we have to use the specific name that the site provides to work correctly. Here's an example:
@import url('https://fonts.googleapis.com/css?family=Titillium+Web');
Using the font in% desired%:
h1 {
font-family: 'Titillium Web', sans-serif;
}
In addition to the security of using Google Web Fonts fonts, we also have the facility, without having to download anything, just by copying the path of the desired font that is already hosted on the google servers and specifying its name in your CSS file .
References:
link
link
link
link
link