1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

font-familyの間違いやすい設定

Posted at

まずはこちらの設定をみてください。

image.png

みなさん、この設定のどこがおかしいか分かりますか?

実は"sans-serif"というのが間違っています。
え、"Montserrat"は二重引用符で囲ってるから、sans-serifも囲むんじゃないの?って思いますよね。
実はフォントにはフォントファミリー名と総称フォント名の2種類あって区別する必要があるんです。

フォントファミリー名と総称フォント名

フォントファミリー名はエクセルやワードなどでもよくみる「メイリオ」や「Arial」などの具体的な欧文フォント名、日本語フォント名を指します。

一方で総称フォント名とはゴシック体や明朝体など、フォントファミリー名よりも大きなカテゴリーのフォント名を指します。

CSSでのfont-familyではフォントファミリー名か総称フォント名かで指定の仕方が異なる

一応どっちも二重引用符をつけてもエラーにはならないのですが、ブラウザが二重引用符がついているものはフォントファミリー名として認識してしまうため、意図しない動きになる可能性があります。

そのため、フォントファミリー名か総称フォント名かちゃんと区別して設定しましょう。

まとめ

フォントファミリー名:二重引用符でくくる
総称フォント名:そのまま記述する

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?