Font outline using only CSS

AndrewLeonardi picture AndrewLeonardi · Aug 12, 2019 · Viewed 8.3k times · Source

I'm working on adding a black font outline to white text using CSS. The goal is the image below. So far I've been able to come up with below. Is there any other best practice to closer match the thin outline shown in the image below? Thanks!

enter image description here

Answer

Azametzin picture Azametzin · Aug 12, 2019

One way to do that is to use text-shadow and overlap multiple shadows:

.introText {
   text-shadow: 0 0 1px black, 0 0 1px black, 0 0 1px black, 0 0 1px black;
}

4 times in this case.

Example:

.introText {
        font-family: "Nunito", sans-serif;
        text-shadow: 0 0 1px black, 0 0 1px black, 0 0 1px black, 0 0 1px black; 
        color: white;
        font-size: 50px;
        margin-top: 20vh;
      }
    <h1 class="introText text-center">We've got your perfect spot.</h1>

It creates a very similar effect and you can make it stronger or weaker depending on how many repetitions you use.