본문 바로가기
HTML + CSS + 자바스크립트

구글 폰트(Google Fonts) 사용법

by Ellie.P 2023. 11. 29.
반응형

⬇ 구글 폰트에서 원하는 글꼴 찾기 ⬇

 

Browse Fonts - Google Fonts

Making the web more beautiful, fast, and open through great typography

fonts.google.com

사용한 글꼴 : Inconsolata

@import 로 글꼴 적용하기

⭐️ import 부분은 반드시 style 태그의 최상단에 위치해야 함 ⭐️

<!DOCTYPE html>
<html lang="ko">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Web Font</title>
  <style>
    @import url('https://fonts.googleapis.com/css2?family=Inconsolata&display=swap');
    p {
      font-family: 'Inconsolata', monospace;
    }
  </style>
</head>
<body>
  <p>Welcome, Ellie Programming World</p>
  <p>Ellie Trip World 도 놀러오세요</p>
  <a href="https://ellie-kang.tistory.com/">Ellie Trip World 바로가기</a>
</body>
</html>
Web Font

Welcome, Ellie Programming World

Ellie Trip World 도 놀러오세요

Ellie Trip World 바로가기

<link> 로 글꼴 적용하기

<!DOCTYPE html>
<html lang="ko">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Web Font</title>
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Inconsolata&display=swap" rel="stylesheet">
  <style>
    p {
      font-family: 'Inconsolata', monospace;
    }
  </style>
</head>
<body>
  <p>Welcome, Ellie Programming World</p>
  <p>Ellie Trip World 도 놀러오세요</p>
  <a href="https://ellie-kang.tistory.com/">Ellie Trip World 바로가기</a>
</body>
</html>
Web Font

Welcome, Ellie Programming World

Ellie Trip World 도 놀러오세요

Ellie Trip World 바로가기

 

미리보기로 알수 있듯이

<link>와 @import 두 방법모두

p태그를 사용한 글자들은 Inconsolata 글꼴이 잘 적용되었다 👍

 

반응형