<div class="text-truncate" style="width: 150px;">This is a very long text that should be truncated.</div>
The text-truncate class in Bootstrap applies overflow: hidden, text-overflow: ellipsis, and white-space: nowrap to truncate overflowing text with an ellipsis.
text-nowrap class to prevent text from wrapping?<p class="text-nowrap">This text will not wrap to the next line.</p>
The text-nowrap class applies white-space: nowrap; which prevents the text from wrapping to the next line.
<div class="text-break" style="width: 100px; border: 1px solid black;">Supercalifragilisticexpialidocious</div>
What will you see in the browser?
<div class="text-break" style="width: 100px; border: 1px solid black;">Supercalifragilisticexpialidocious</div>
text-break allows breaking inside words to wrap.The text-break class applies word-break: break-word; which forces long words to break and wrap inside the container.
<div class="???" style="width: 200px; border: 1px solid #000;">This is a long text that should wrap properly inside the box without overflow.</div>
The text-wrap class applies overflow-wrap: break-word; allowing text to wrap inside the container without overflow. Avoid text-nowrap or text-truncate which prevent wrapping or truncate text.
text-truncate to shorten long text with ellipsis. What should you add to keep the full text accessible to screen readers and keyboard users?<div class="text-truncate" style="width: 150px;">This is a very long text that should be truncated.</div>
When text is truncated visually, adding aria-label with the full text ensures screen readers can read the complete content. This improves accessibility for users relying on assistive technologies.