1

I am creating a multilingual website where the plugin in I am using only provides the option to show the language name entirely. I want to limit the character count to only 3 characters. Example: If the language is English I only want to display it as ENG, When it's Vietnamese it will be VIE.

I already tried

span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 50px;
  display: inline-block;
  text-transform: uppercase;
  font-size: 15px;
}
<p>
  <span>English</span>
</p>
<p>
  <span>Vietnamese</span>
</p>

I don't want the ... appear with the first three letters and setting a width or max-width is not effective to show only 3 characters in some languages as you see in the above snippet. Is there are any alternative approaches there? Let me know, please.

Ramesh
  • 2,297
  • 2
  • 20
  • 42
  • Related. https://stackoverflow.com/questions/26973570/setting-a-max-character-length-in-css/26975271#26975271 – Paulie_D Dec 12 '20 at 07:54

1 Answers1

0

that ? with font-family:monospace;

span {
  font-size      : 30px;
  display        : inline-block;
  width          : 3ch;
  font-family    : monospace;
  overflow       : hidden;
  text-transform : uppercase;
}
<p>
  <span>English</span>
</p>
<p>
  <span>Vietnamese</span>
</p>
Mister Jojo
  • 20,093
  • 6
  • 21
  • 40