css span limit text code example

Example 1: span limit text length

<style>
	.text {
  		display: block;
  		width: 100px;
  		overflow: hidden;
  		white-space: nowrap;
  		text-overflow: ellipsis;
	}
</style>
<span class="text">Hello world this is a long sentence</span>

Example 2: text limit in css

body {
   margin: 20px;
}

.text {
   overflow: hidden;
   text-overflow: ellipsis;
   display: -webkit-box;
   -webkit-line-clamp: 2; /* number of lines to show */
   -webkit-box-orient: vertical;
}

Example 3: css text limit

p {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

Tags:

Css Example