# Changing font family on casper theme

**URL:** <https://forum.ghost.org/t/changing-font-family-on-casper-theme/33380>\
**Category:** Developer help\
**Created:** [October 11, 2022, 5:08am UTC](https://forum.ghost.org/t/changing-font-family-on-casper-theme/33380 "2022-10-11T05:08:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yuknet](https://avatars.discourse-cdn.com/v4/letter/y/ad7895/32.png) [@yuknet](https://forum.ghost.org/u/yuknet)\
**Post date:** [October 11, 2022, 5:08am UTC](https://forum.ghost.org/t/changing-font-family-on-casper-theme/33380/1 "2022-10-11T05:08:25Z")

</div>

I want to change the font-family of the default casper theme. I’ve injected code like so in the header but it doesn’t seem to work. When I do inspect element I’m getting this which overrides the code injected above. How can I fix this?  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/3X/a/a/aa21cb811caae88f569dec6d13c3ba1ff8f5891c.png)

```auto
<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=Open+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,300;1,400;1,500;1,600;1,700;1,800&family=Oxygen:wght@300;400;700&display=swap" rel="stylesheet"> 

<style>
    html, body {
     	font-family: 'Open Sans', sans-serif;
    }
    title {
        font-family: 'Oxygen', sans-serif;
    }

```

- **What’s your URL**? [blog.agentzhao.me](http://blog.agentzhao.me)
- **What version of Ghost are you using?** 5.0

And

- How was Ghost installed and configured? docker + mariadb
- What Node version, database, OS & browser are you using? v12.22.9
- What errors or information do you see in the console? nil
- What steps could someone else take to reproduce the issue you’re having? default casper theme

Appreciate any help!

---

<div class="post-metadata">

**Author:** ![denvergeeks](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/denvergeeks/32/7401_2.png) [@denvergeeks](https://forum.ghost.org/u/denvergeeks)\
**Post date:** [October 11, 2022, 4:11pm UTC](https://forum.ghost.org/t/changing-font-family-on-casper-theme/33380/2 "2022-10-11T16:11:58Z")

</div>

@yuknet you can try using CSS **!important** …

> **[When Using !important is The Right Choice | CSS-Tricks](https://css-tricks.com/when-using-important-is-the-right-choice/)**
>
> Using !important rules can be a dangerous road to start going down, but they exist for a reason. There are some good use cases which we'll cover here.

---

<div class="post-metadata">

**Author:** ![RyanF](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/ryanf/32/17448_2.png) [@RyanF](https://forum.ghost.org/u/RyanF)\
**Post date:** [October 11, 2022, 7:05pm UTC](https://forum.ghost.org/t/changing-font-family-on-casper-theme/33380/3 "2022-10-11T19:05:44Z")

</div>

The trouble here is that the Ghost class (`.gh-content > p`) has more specificity than your CSS, so it overrides it. Also, `title` won’t work to target your headings (you need to list them explicitly like h1, h2…).

Try this:

```css
<style>
html {
  font-family: "Open Sans", sans-serif;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: "Oxygen", sans-serif;
}

.gh-content > p {
  font-family: "Open Sans", sans-serif;
}
</style>

```

Finally, you should add this snippet to your site’s **Code Injection** → **Site Header**. That way, it’ll come after the default styles and override them.

> **[How to use Code Injection in Ghost](https://ghost.org/tutorials/use-code-injection-in-ghost/)**
>
> Code Injection is a powerful, convenient tool to add CSS, JS, and more to your Ghost site. Learn how to get the most out of it in this tutorial.

---

<div class="post-metadata">

**Author:** ![yuknet](https://avatars.discourse-cdn.com/v4/letter/y/ad7895/32.png) [@yuknet](https://forum.ghost.org/u/yuknet)\
**Post date:** [October 12, 2022, 6:03am UTC](https://forum.ghost.org/t/changing-font-family-on-casper-theme/33380/4 "2022-10-12T06:03:42Z")

</div>

It worked! Thank you so much!
