Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set font-family to specific symbols in CSS

Tags:

html

css

fonts

On my website i use non standard cyrillic font. It looks well but it have problems with some special symbols, for example - quotes (for some reason opening and ending quote look different).

I would like to set font-family for specific symbols using CSS. Is it possible?

like image 894
moonvader Avatar asked Sep 14 '15 08:09

moonvader


1 Answers

You can manage this using a unicode range @font-face rule

MDN Reference

I'm unsure as to how well this demo will work in a Snippet as it will depend on you have the designated font installed. However, in general, it's something like this:

@font-face {

  font-family: 'Algerian';
  src: local('Algerian');
  unicode-range: U+022-026;

}

div {
  font-size: 4em;
  font-family: Algerian, sans-serif;

}

div {
  text-align: center;

}

p {
  font-size: 72px;

}
<div>
  <p>" Lorem & Ipsum "</p>
</div>

In this instance I've applied the rule to open & closed quotes and the ampersand.

Support: CanIUse.com

For Firefox though:

Support can be enabled in Firefox using the layout.css.unicode-range.enabled flag

like image 145
Paulie_D Avatar answered Sep 21 '22 22:09

Paulie_D