CSS no text wrap

HtmlCssText

Html Problem Overview


Please see see code http://jsbin.com/eveqe3/edit, also quoted below.

I need to show text inside the item divs in such a way the text appear only in the green box with specified width rest of the line need to be hidden. Any suggestions please...

<style>
  #container{
    width : 220px;
  }
  .item{
    float:left;
    border: 1px solid #0a0;
    width: 100px;
    height: 12px;
    padding 2px;
    margin: 0px 2px;
  }
  .clearfix{
    clear: both;
  }
</style>
</head>
<body>
  <div id="container">
    <div class="item"> A very loooooooooooooooooooooong text </div>
    <div class="item"> Another looooooooooooooooooooong text </div>
    <div class="clearfix">  </div>
   </div>
</body>
</html>

Html Solutions


Solution 1 - Html

Additionally to overflow:hidden, use

white-space:nowrap;

Solution 2 - Html

Just use:

overflow: hidden;
white-space: nowrap;

In your item's divs

Solution 3 - Html

Use the css property overflow . For example:

  .item{
    width : 100px;
    overflow:hidden;
  }

The overflow property can have one of many values like ( hidden , scroll , visible ) .. you can als control the overflow in one direction only using overflow-x or overflow-y.

I hope this helps.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMithun SreedharanView Question on Stackoverflow
Solution 1 - Htmlxor_eqView Answer on Stackoverflow
Solution 2 - HtmlMacmadeView Answer on Stackoverflow
Solution 3 - HtmlAhmed AmanView Answer on Stackoverflow