css max text lines code example

Example 1: css textarea set max characters

<!DOCTYPE html>
<html>
   <head>
      <title>HTML textarea Tag</title>
   </head>

   <body>
      <textarea rows = "5" cols = "40" maxlength = "100" name = "description">
            Enter answer here...
         </textarea>
      
   </body>
</html>

Example 2: css n number of lines only

.className{
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;

   line-height: 16px; /* Height taken by one line */
   max-height: 32px; /* (line-height * numberOfLineYouWant) In this case we want 2 lines so we will multiply lineHeight by 2 so 16 * 2 = 32 => 32px */
						/* Remember if you have more height then it'll render new line so match height of container with => lineHeight * numberOfLines */
}

Tags:

Css Example