CSS Property Value How to - text-overflow: ellipsis








Question

We would like to know how to text-overflow: ellipsis.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.wtf {<!-- w ww. j ava2s.  c  o  m-->
  width: 250px;
  overflow-x: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin: 0;
  padding: 0;
}
</style>
</head>
<body>
  <div contenteditable="true">
    <p class="wtf">WHAT IS HAPPENING asdfkjas dflkasd jfalskdfj
      asldkfj asldkf</p>
    <p class="wtf">SECOND LINE and it also needs to have an ellipsis</p>
  </div>
</body>
</html>

The code above is rendered as follows: