Search code examples
cssstrokeoutline

Using CSS, how do you create a text stroke outline that is *thicker* than 1px?


Below is the code I was using to do a Text Stroke outline of 1px. But how do I get the outline thicker? If I just replace all "1px" with "5px", the result looks crazy.

HTML

<div class="element">
Hello!
</div>

CSS

.element {
color:white;

    text-shadow:
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000;
}

Solution

  • You might use SVG as well, though it requires more code:

    .element {
      font-size: 50px;
    }
    
    svg {
      width: 100%;
      height: 1.3em;
    }
    
    svg text {
      fill: pink;
      stroke-width: 8px;
      paint-order: stroke;
      stroke: violet;
    }
    <div class="element">
      <svg><text x="8px" y="75%">Hello kitty!</text></svg>
    </div>