DEV Community


Posted on

What is webkit-line-clamp?

The interesting thing of reviewing someone else's code is that you discover things you didn't know. That way I learned today about webkit-line-clamp. My first thought was to decline the vendor prefixed property, but I was really surprised to find out that it got standardized for legacy support!

So what does it do? webkit-line-clamp is basically a multi-line ellipsis. You can specify a certain number of lines and the last one will end in an ellipsis.

p {
  width: 300px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
Enter fullscreen mode Exit fullscreen mode

Discussion (0)