Force break short words

Is it possible to break a short words by force, even when elements' width is larger? I don't need to minimize width, just want to add some padding around, also do not want to use <br>. TRIED:
word-break / overflow-wrap / inline-size
word-break / overflow-wrap / inline-size
<a href='#'>Short word</a>

a{
padding: 6px 10px;
word-break: break-all;
}
<a href='#'>Short word</a>

a{
padding: 6px 10px;
word-break: break-all;
}
13 Replies
vince
vince15mo ago
Can you give me an example? I don't follow word-break: break-all; should be what you're looking for, but you said you tried that?
MarkBoots
MarkBoots15mo ago
So, you want a new line after the space if i'm correct? Even if there is enough space for only 1 line? no, without a newline character or a break, don't think that'll work. maybe if change to a display:inline-block (or grid/flex), then you could use width: min-content But don't know if that suits your situation
MarkBoots
MarkBoots15mo ago
No description
Como
ComoOP15mo ago
I mean that i have one sentence that has two words. I want those word to break (to be one under another). Also to add some spacing with padding to make itself (element, in this case <a>) to be a little bit wider i can try to make it using figma for example, i will sent you an image
ἔρως
ἔρως15mo ago
why don't you use the <wbr> element? it will automatically break then there isn't enough space or just use a <br> which is exactly what that element is for
Como
ComoOP15mo ago
i dont want to use <br> thats the point
Como
ComoOP15mo ago
there is an example
No description
Como
ComoOP15mo ago
those green lines for padding
ἔρως
ἔρως15mo ago
is there any reason to do not want to use it?
Como
ComoOP15mo ago
i always tried to not use it. I just dont like it. But if there is no way to do this without <br> then i will use this tag
ἔρως
ἔρως15mo ago
it's certainly the easiest way to achieve it
Como
ComoOP15mo ago
this works, thank you
snxxwyy
snxxwyy15mo ago
If nothing else works you can just give it a max width of however many characters the first word has, for example max-width: 10ch;
Want results from more Discord servers?
Add your server