search

Home  >  Q&A  >  body text

Weird lines when using "background-clip: text" on Safari

I'm trying to make gradient text using CSS. Currently it works in Chrome and Firefox, but on Safari I see weird lines outside the borders.

My CSS looks like this...

h1 {
    font-family: "Work Sans", Helvetica, Arial, sans-serif;
}

.highlighted {
    color: transparent;
    background: linear-gradient(90deg, #FF008B, #FF006B);
    background-clip: text;
    -webkit-background-clip: text;
}

My HTML is just a simple...

<h1>Welcome to <span class="highlighted">My site</span></h1>

But on Safari it will render like this.

Can someone help me fix these lines?

P粉788765679P粉788765679382 days ago537

reply all(1)I'll reply

  • P粉262113569

    P粉2621135692024-01-05 21:12:33

    You can try clip-path to fix it:

    h1 {
      font-family: "Work Sans", Helvetica, Arial, sans-serif;
    }
    
    .highlighted {
      color: transparent;
      background: linear-gradient(90deg, #FF008B, #FF006B);
      -webkit-background-clip: text;
              background-clip: text;
      padding: 1px;
      clip-path: inset(1px);
    }
    <h1>Welcome to <span class="highlighted">My site</span></h1>

    reply
    0
  • Cancelreply