Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opposite of ­ [duplicate]

Tags:

html

css

Is there a way to not break a word at a specific point? Something like the opposite of &shy?

I've set my text to hyphens: auto; but at a specific point the word breaks which is incorrect. I already set &shy at multiple spots in the word, but it still breaks at the wrong point.

I want to insert something in the html (no css or anything because it has to work editorial) that tells the browser to never break at this point no matter what.

like image 414
skarpeta Avatar asked Nov 07 '22 01:11

skarpeta


1 Answers

AFAIK there's no explicit HTML special char to do this.

One workaround might be to specify your whole content to be breakable anywhere, and wrap the unbreakable parts of your word in a span without word-break.

Then, you can decide in your editor where you'll want the word to stop:

.breakable {
  word-break: break-all;
}
.unbreakable {
  word-break: normal;
  color: red;
}
<div class="breakable">Browser can break anywhere here, but not where I decide: on this <span class="unbreakable">specificsuperlong</span>wordofmine, the red part is unbreakable. </div>
<div class="breakable">If I want to decide a special position it can only split on, I wrap my special <span class="unbreakable">unbrea</span>k<span class="unbreakable">able</span> in two spans.</div>
like image 169
Bigood Avatar answered Nov 15 '22 08:11

Bigood