J.BF Story

[CSS] 전체 요소에 font-family 적용하기 본문

FrontEnd/CSS

[CSS] 전체 요소에 font-family 적용하기

J.BF 2022. 7. 8. 23:53

전체 요소에 'font-family'를 통해 글꼴을 정해줄 때 처음에는 다음과 같이 <body>요소를 통해 적용하였다.

그러나 <button>, <input>, <textarea> 요소에는 글꼴이 적용되지 않은 것을 발견하였다.

<style>
    @import url('https://fonts.googleapis.com/css2?family=Raleway&display=swap');

    body {
        font-family: 'Raleway', sans-serif;
    }
</style>

<h2>Hello world</h2>
<button>Hello world</button>
<input type="text" value="Hello world"></input>
<textarea>Hello world</textarea>

따라서 다음과 같이 <body> 요소 뿐만 아니라, <button>, <input>, <textarea>에도 'font-family'를 적용시켜줘야한다.

<style>
    @import url('https://fonts.googleapis.com/css2?family=Raleway&display=swap');

    body, button, input, textarea {
        font-family: 'Raleway', sans-serif;
    }
</style>

<h2>Hello world</h2>
<button>Hello world</button>
<input type="text" value="Hello world"></input>
<textarea>Hello world</textarea>

 

Comments