How To Make CSS Ellipsis Work On A Table Cell - W3docs

w3docs logo Books Learn HTML Learn CSS Learn Git Learn Javascript Learn PHP Learn python Learn Java Exercises HTML JavaScript Git CSS PHP Courses Quizzes Snippets Tools General Tools
  • Password Generator
  • HTML Editor
  • HTML Encoder
  • Base 64
  • Code Diff
  • JSON Beautifier
  • CSS Beautifier
  • Markdown Convertor
  • Find the Closest Tailwind CSS Color
  • Phrase encrypt / decrypt
  • Browser Feature Detection
  • Number convertor
CSS Maker
  • CSS Maker
  • CSS Maker text shadow
  • CSS Maker Text Rotation
  • CSS Maker Out Line
  • CSS Maker RGB Shadow
  • CSS Maker Transform
  • CSS Maker Font Face
Color Tools
  • Color Picker
  • Colors CMYK
  • Colors HWB
  • Colors HSL
  • Color Hex
  • Color mixer
  • Color Converter
  • Colors RGB
  • Color Contrast Analyzer
  • Color Gradient
String Tools
  • String Length Calculator
  • MD5 Hash Generator
  • Sha256 Hash Generator
  • String Reverse
  • URL Encoder
  • URL Decoder
  • Base 64 Encoder
  • Base 64 Decoder
  • Extra Spaces Remover
  • String to Lowercase
  • String to Uppercase
  • Word Count Calculator
  • Empty Lines Remover
  • HTML Tags Remover
  • Binary to Hex
  • Hex to Binary
  • Rot13 Transform on a String
  • String to Binary
  • Duplicate Lines Remover
Change theme
  • Dark
  • Light
  • System
  • Books
    • Learn HTML
    • Learn CSS
    • Learn Git
    • Learn Javascript
    • Learn PHP
    • Learn python
    • Learn Java
  • How To
    • How To NodeJs
    • How To Linux
    • How To AngularJs
    • How To PHP
    • How To HTML
    • How To CSS
    • How To Symfony
    • How To Git
    • How To Apache
    • How To JavaScript
    • How To Java
    • How To Vue.js
    • How To Python
  1. Snippets
  2. CSS
  3. How To Make CSS Ellipsis Work on a Table Cell
How To Make CSS Ellipsis Work on a Table Cell

Solution with the CSS display property

To make an ellipsis work on a table cell, you can use the CSS display property set to its "block" or "inline-block" value.

In our example below, besides the display property, we set the text-overflow to "ellipsis", use the "nowrap" value of the white-space property, set the overflow to "hidden". Also, we specify the width and border of our <td> element.

Example of adding an ellipsis on a table cell with the CSS display property:

<!DOCTYPE html> <html> <head> <title>Title of the document</title> <style> td { display: block; border: 2px solid #000; width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } </style> </head> <body> <table> <tbody> <tr> <td>Hello World</td> </tr> </tbody> </table> </body> </html> Try it Yourself »

Result

Hello World

Solution with the CSS table-layout property

Another possible way of making an ellipsis work on a table cell is using the CSS table-layout property with its "fixed" value on the <table> and specifying its width.

Example of adding an ellipsis on a table cell with the CSS table-layout and width properties:

<!DOCTYPE html> <html> <head> <title>Title of the document</title> <style> table { table-layout: fixed; width: 60px; } td { border: 2px solid #000; width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } </style> </head> <body> <table> <tbody> <tr> <td>Hello World</td> </tr> </tbody> </table> </body> </html> Try it Yourself » Tags ellipsis html css

Related Resources

  • How to Display Ellipsis in the <span> Element Having Hidden Overflow
  • How to Limit the Text Length to One Line with CSS
Sorry about that How can we improve it? Submit Thanks for your feedback! Thanks for your feedback! Do you find this helpful? Yes No Quizzes
  • PHP basics
  • HTML Basics
  • Javascript Basics
  • CSS Basics
  • ES6 Basics
  • TypeScript Basics
  • React Basics
  • Angular Basics
  • Sass Basics
  • Git Basics
  • Vue.js Basics
  • SQL Basics
  • Python Basics
  • Java Basics
  • NodeJS Basics

Từ khóa » Html Table Td Text Too Long