Treehouse: Grow your CSS skills. Land your dream job.

How to make a sentence stay inline?

  • # May 12, 2010 at 4:17 am

    Hello everyone,

    I have a small box (fixed width and height) with some text in it. It’s great if the string fits in it or if it’s just one word (even if too long), then only the part that fits is visible (using overflow:hidden). The problem is, that if the string is more than one word I would like it to stay on the line and just hide what doesn’t fit without the text going to the other line.

    I hope I made myself clear.
    If not, maybe this will:
    Live example here:

    Any help would be greatly appreciated!

    # May 12, 2010 at 9:16 am

    The easiest solution that comes to me is to wrap the text in a <p></p>, then set a higher width than the divs’ one.

    # May 12, 2010 at 10:31 am

    Just add

    # May 12, 2010 at 11:30 am

    Exactly what needed! Thank you so much!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.