HTML Academy
Text Direction and Tables
Text Formatting23/26
Back to the list of tasks
  • 1. Unicode Characters
  • 2. The text-shadow Property
  • 3. Horizontal Text Shadow Offset
  • 4. Vertical Text Shadow Offset
  • 5. Text Shadow Blur
  • 6. The Text Shadow Color
  • 7. Recessed Effect for Text
  • 8. Decorative Retro Shadow
  • 9. Challenge: Psychedelic Shadows
  • 10. Logo: Custom Font
  • 11. Logo: Icon Font
  • 12. Logo: Size Alignment
  • 13. Applying Decorative Styling to the Line, Step 1
  • 14. Applying Decorative Styling to the Line, Step 2
  • 15. The text-indent Property
  • 16. The ::first-letter Pseudo-element
  • 17. The ::first-line Pseudo-element
  • 18. Column Markup: The column-count Property
  • 19. Column Markup: The column-width Property
  • 20. Column Markup: The column-gap Property
  • 21. Text Direction
  • 22. Text Direction and Tables
  • 23. Overflowing Text
  • 24. Spacing Between Words
  • 25. Challenge: Why So Serious?
  • 26. Challenge: Play With Fonts
Spacing Between Words
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Overflowing Text

Another interesting text property is text-overflow. It allows you to determine how the text will look if it does not fit in the container. It takes different values, but clip and ellipsis are universal and work in all modern browsers.

The clip value is set by default, and it will simply cut text to fit the size of the container, whereas ellipsis will cut it and add an ellipsis to the end of the line.

This property handles text that overflows a line within a block container. To see the effect, the container’s overflow must be something other than visible, such as hidden. For a single-line ellipsis, we’ll also prevent wrapping with white-space: nowrap.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <title>Overflowing Text</title> <meta charset="utf-8"> <link rel="stylesheet" href="style.css"> </head> <body> <p>Muffin woke up in his cat bed very early that morning. The day promised to be eventful. Due to this, he decided to work out on his chin-up bar. The cat eventually tired himself out exercising, and he decided to relax a bit and watch TV. Having regained his strength, the cat went about his usual business of making a mess. However, he was caught in the act.</p> </body> </html>
CSS
body { background: url("bokeh.jpg") no-repeat 50% 0; color: #333333; font-size: 12px; font-family: "Arial", sans-serif; } p { margin: 50px auto; padding: 20px; width: 50%; background-color: rgba(240, 240, 240, 0.85); font-size: 16px; line-height: 22px; }

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

The code has changed, click “Refresh” or turn autorun on.

You’ve gone to a different page

Click inside the mini-browser to shift the focus onto this window.

100%
Goalscompleted
0
    1. Assign the properties white-space: nowrap and overflow: hidden to the paragraph,
    2. and then assign the text-overflow mode with the value ellipsis.

    Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2026

    VISAMastercard

    Log in

    or

    Forgot your password?

    Sign up

    Sign up

    or
    Log in

    Restore access

    Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

    Forgot to connect your email to the profile? Email us and we’ll help.