4

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;
}
m0a
  • 1,005
  • 2
  • 15
  • 29

2 Answers2

7

You can consider text-stroke but you need to pay attention to browser support

.element {
  color: white;
  font-size:50px;
  -webkit-text-stroke: 5px #000;
}
<div class="element">
  Hello!
</div>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415
  • 1
    Interestingly, this css property has been in webkit for more than a decade, but it's still not part of the official css spec. – Håken Lid Jul 21 '18 at 20:30
  • Didn't know this property. It would be very useful in mobile dev. – Kosh Jul 21 '18 at 20:54
3

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>
Kosh
  • 16,966
  • 2
  • 19
  • 34