The <code>.text-wrap</code> class allows text to wrap onto the next line instead of overflowing outside its container.
Click to reveal answer
beginner
How does the Bootstrap class .text-nowrap affect text?
The <code>.text-nowrap</code> class prevents text from wrapping. All text stays on one line and may overflow its container if too long.
Click to reveal answer
beginner
What is the purpose of the Bootstrap class .text-truncate?
The <code>.text-truncate</code> class shortens text that is too long to fit in its container by adding an ellipsis (...) at the end.
Click to reveal answer
intermediate
Which CSS property does Bootstrap's .text-truncate rely on to show ellipsis?
It uses the CSS property text-overflow: ellipsis; combined with overflow: hidden; and white-space: nowrap;.
Click to reveal answer
beginner
Why is controlling text overflow important in web design?
Controlling text overflow keeps layouts neat and readable. It prevents text from spilling outside containers, which can break design and confuse users.
Click to reveal answer
Which Bootstrap class allows text to wrap onto multiple lines?
A.text-nowrap
B.text-truncate
C.text-wrap
D.text-break
✗ Incorrect
The .text-wrap class enables text to wrap onto the next line.
What happens when you use .text-nowrap on a long text?
AText wraps to next line
BText becomes bold
CText is truncated with ellipsis
DText stays on one line and may overflow
✗ Incorrect
.text-nowrap keeps text on one line, which can cause overflow.
Which class would you use to shorten overflowing text with an ellipsis?
A.text-truncate
B.text-nowrap
C.text-wrap
D.text-break
✗ Incorrect
.text-truncate shortens text and adds an ellipsis.
What CSS property is essential for showing ellipsis in truncated text?
Atext-overflow: ellipsis;
Boverflow: visible;
Cwhite-space: normal;
Ddisplay: block;
✗ Incorrect
text-overflow: ellipsis; shows the three dots for truncated text.
Why should you avoid letting text overflow its container?
AIt improves page loading speed
BIt keeps the layout clean and readable
CIt makes text bold
DIt changes font color
✗ Incorrect
Preventing overflow keeps the page neat and easy to read.
Explain how Bootstrap helps manage text wrapping and overflow in layouts.
Think about how text behaves when it is too long for its container.
You got /4 concepts.
Describe the CSS properties behind Bootstrap's text truncation feature.
These properties work together to hide overflow and show dots.
You got /3 concepts.
Practice
(1/5)
1. Which Bootstrap class allows text to wrap normally within its container?
easy
A. .text-break
B. .text-nowrap
C. .text-truncate
D. .text-wrap
Solution
Step 1: Understand text wrapping classes in Bootstrap
Bootstrap provides .text-wrap to allow normal text wrapping inside containers.
Step 2: Identify the class that enables wrapping
.text-nowrap prevents wrapping, and .text-truncate truncates text with ellipsis. So, .text-wrap is the correct choice.
Final Answer:
.text-wrap -> Option D
Quick Check:
Text wrapping = .text-wrap [OK]
Hint: Wrap text? Use .text-wrap class [OK]
Common Mistakes:
Confusing .text-nowrap as wrapping text
Thinking .text-truncate wraps text
Assuming .text-break is for wrapping
2. Which of the following is the correct Bootstrap class to prevent text from wrapping?
easy
A. .text-wrap
B. .text-nowrap
C. .text-truncate
D. .text-break
Solution
Step 1: Recall Bootstrap classes for text wrapping control
.text-nowrap is designed to stop text from wrapping onto the next line.
Step 2: Confirm the class that disables wrapping
.text-wrap allows wrapping, .text-truncate truncates text, so .text-nowrap is the correct class to prevent wrapping.
Final Answer:
.text-nowrap -> Option B
Quick Check:
No wrap = .text-nowrap [OK]
Hint: Stop wrapping? Use .text-nowrap class [OK]
Common Mistakes:
Using .text-wrap to stop wrapping
Confusing .text-truncate with no wrap
Assuming .text-break stops wrapping
3. What will be the visual result of this HTML snippet using Bootstrap?
<div class='text-truncate' style='width: 8rem;'>This is a very long text that should be cut off.</div>
medium
A. The text will be cut off with an ellipsis (...) at the end within 8rem width.
B. The text will stay on one line and overflow outside the box.
C. The full text will wrap into multiple lines within 8rem width.
D. The text will break words to fit inside the box without ellipsis.
Solution
Step 1: Understand .text-truncate behavior
The .text-truncate class in Bootstrap truncates text that overflows its container and adds an ellipsis.
Step 2: Analyze the style and effect
The container width is limited to 8rem, so the long text will not fit and will be cut off with an ellipsis on one line.
Final Answer:
Text cut off with ellipsis within 8rem width -> Option A
Quick Check:
.text-truncate = ellipsis cut off [OK]
Hint: Use .text-truncate for ellipsis on overflow [OK]
Common Mistakes:
Expecting text to wrap with .text-truncate
Thinking text overflows visibly without cut off
Confusing .text-truncate with .text-nowrap
4. You want to prevent text wrapping but also show an ellipsis if the text is too long. Which Bootstrap classes combination is correct?
medium
A. .text-nowrap .text-truncate
B. .text-wrap .text-truncate
C. .text-nowrap .text-wrap
D. .text-truncate .text-wrap
Solution
Step 1: Identify classes for no wrap and truncation
.text-nowrap stops wrapping, and .text-truncate adds ellipsis for overflow.
Step 2: Combine classes correctly
Using .text-nowrap .text-truncate together prevents wrapping and truncates overflow with ellipsis.
Final Answer:
.text-nowrap .text-truncate -> Option A
Quick Check:
No wrap + ellipsis = .text-nowrap .text-truncate [OK]
Hint: Combine .text-nowrap and .text-truncate for no wrap + ellipsis [OK]
Common Mistakes:
Using .text-wrap with .text-truncate (conflicting)
Not combining classes, only using one
Mixing order incorrectly
5. You have a responsive card with a title that might be very long. You want the title to stay on one line, show ellipsis if too long, and be accessible for screen readers. Which Bootstrap and HTML approach is best?
hard
A. <h5 class='text-nowrap text-truncate' style='max-width: 100%;'>Long title</h5>
B. <h5 class='text-wrap'>Long title</h5>
C. <h5 class='text-nowrap text-truncate' style='max-width: 15rem;' title='Long title'>Long title</h5>
D. <h5 class='text-truncate' style='max-width: 15rem;'>Long title</h5>
Solution
Step 1: Ensure no wrapping and truncation
Use .text-nowrap to prevent wrapping and .text-truncate to add ellipsis for overflow.
Step 2: Set a max-width and add accessibility
Limit width with max-width: 15rem; so truncation works. Add title attribute to show full text on hover for screen readers and keyboard users.