hide text if too long css code example

Example 1: css overflow truncate

//Truncate text overflow 
.element {
	white-space: nowrap;
  	overflow: hidden;
  	text-overflow: ellipsis;
}

Example 2: css hide text if too long

<div id="truncateLongTexts">
    test test test test
</div>

#truncateLongTexts {
  width: 100px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis // This is where the magic happens
}

Example 3: truncate text css

.element{

  text-overflow: ellipsis;

  /* Required for text-overflow to do anything */
  white-space: nowrap;
  overflow: hidden;
}

Tags:

Css Example