E
E
Eugene Ordinary2017-04-21 20:08:07
css
Eugene Ordinary, 2017-04-21 20:08:07

How does @font-face work?

@font-face {
    font-family: "Computer Modern";
    src: url('/fonts/cmunbmr.ttf');
  }
@font-face {
    font-family: "Computer Modern";
    src: url('/fonts/cmunbbx.ttf');
    font-weight: bold;
  }
  @font-face {
    font-family: "Computer Modern";
    src: url('/fonts/cmunsi.ttf');
    font-style: italic, oblique;
  }
  @font-face {
    font-family: "Computer Modern";
    src: url('/fonts/cmunbxo.ttf');
    font-weight: bold;
    font-style: italic, oblique;
  }
Do I understand correctly that the font-weight, font-style properties are parameters or selectors that determine the choice of font by the browser?
Is it true that if you write
<p style="font-family: 'Computer Modern';  font-style: italic;">Текст</p>
then the font from the cmunsi.ttf file will be used, but in such a construction cmunbxo.ttf will be used?
<i><b>Текст</b></i>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Let 's say, 2017-04-21
@DopustimVladimir

@font-face essentially allows you to add a font to use.
True if the font is specified in the selector for the element, or its parent.

body {
  font-family: 'Computer Modern';
}

And it is still desirable to separate CSS rules from HTML
.some-class {
  font-family: 'Computer Modern';
  font-style: italic;
}

will look neater and easier to work with (you only change styles in CSS, and only markup in HTML)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question