Connecting fonts in CSS

If you do not delve into the details, you can quickly connect the font like this:

/* Normal */
@font-face {
	font-family: 'FontName'; 
	src: url(/fonts/font.ttf); 
}

/* Bold */
@font-face {
	font-family: 'FontName bold'; 
	src: url(/fonts/font-bold.ttf); 
}

.text-1 {
	font-family: 'FontName'; 
	font-size: 20px;
}

.text-2 {
	font-family: 'FontName bold'; 
	font-size: 20px;
}
CSS

This method works fine in most browsers, but is incorrect. Omitted in this example:

  • There is no font name in the local property.
  • Only one font format is connected.
  • Faces configured incorrectly.
14.02.2020, updated 28.05.2021
113

Comments

to add a comment.

Other publications

CSS styles for horizontal lines
Collection of horizontal lines with hr tag of different types and styles.
95
0
Heading with a horizontal line in the middle
One way to make a heading with a horizontal line in the center without an image (background-image).
83
0
The viewport meta tag
Initially, the viewport meta tag appeared in the mobile version of Safari, then it was picked up by other developers and mobile browsers, although it is not part of the W3C standard.
55
0
Smooth background change
This effect can be easily done through the CSS transition property for example buttons, menus, etc.
296
0
Aligning a block to the center of its parent
Examples of how to position an element in the center of its parent using absolute, flexbox and grid layout.
96
0
Collection of CSS gradients
A selection of 23 backgrounds with linear and radial gradients.
220
0