Home > Article > Web Front-end > Why Isn't My Text Overflow Ellipsis Working?
Text Overflow Ellipsis Not Functioning
The text-overflow property is intended to truncate the displayed text and add an ellipsis (...) to indicate that the full text is not visible. However, if this property is not working as expected, it's crucial to ensure that several key CSS properties are in place.
Required CSS Properties:
To properly activate the text-overflow: ellipsis effect, you must have the following CSS properties defined:
Demo with Correct Code:
The following CSS snippet demonstrates how to correctly apply the necessary properties:
span { border: solid 2px blue; white-space: nowrap; text-overflow: ellipsis; width: 100px; display: block; overflow: hidden; }
Example:
<span>Test test test test test test</span>
By implementing these properties, you can ensure that the specified text will be truncated and display an ellipsis when its container's width is too narrow to accommodate the entire text.
The above is the detailed content of Why Isn't My Text Overflow Ellipsis Working?. For more information, please follow other related articles on the PHP Chinese website!