Home > Back-end >  Remove/hide text with css
Remove/hide text with css

Time:05-05

Let's say I have a p and I want to remove/hide the first two letters. Is there any way I can do that with only CSS (no JS)?

Example:

.remove-letters {
  /* STYLES-HERE */
}
<p >yrHello There!</p>

CodePudding user response:

Without Javascript you cant achieve this very well. It would be a very hacky solution. With JS would be working like a charm.

let str = "yrHello There!"
console.log(str.substring(2))

CodePudding user response:

I think I found a way to do it...

Example:

.remove-letters {
  font-size: 0px;
}

.remove-letters:after {
  font-size: 10px;
  content: "Hello There!";
}
<p >yrHello There!</p>

CodePudding user response:

Just use:

.hidden {
  font-size: 0;
}
<span > Sample Text </span>

:))

  • Related