InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

CSS properties

  • CSS3 flexbox
  • all
  • animation
  • background-color
  • background-image
  • border
  • border-color
  • border-radius
  • border-style
  • border-width
  • bottom
  • box-shadow
  • box-sizing
  • calc function
  • clip
  • color
  • color value currentColor
  • color values
  • cursor
  • float
  • font
  • font-family
  • font-size
  • font-style
  • font-variant
  • font-weight
  • generated content
  • left
  • letter-spacing
  • line-height
  • list-style
  • list-style-image
  • list-style-position
  • list-style-type
  • margin
  • max-height
  • max-width
  • min-height
  • min-width
  • opacity
  • outline
  • outline-color
  • outline-style
  • outline-width
  • overflow
  • padding
  • pointer-events
  • position
  • resize
  • right
  • text-align
  • text-decoration
  • text-indent
  • text-overflow
  • text-shadow
  • text-transform
  • top
  • transform
  • transition
  • transition-delay
  • transition-duration
  • transition-property
  • transition-timing-function
  • visibility
  • white-space
  • word-break
  • word-spacing
  • word-wrap/overflow-wrap
  • z-index
 
  • Home
  • > Tutorials
  • > CSS
  • > CSS properties

CSS text-overflow – truncate text with three dots

on Mar 15, 2016

CSS property text-overflow specifies rendering when inline content overflows its line box edge in its block container element (“the block”) that has overflow other than visible.

CSS property text-overflow

CSS version: CSS 3
Value: clip | ellipsis
Initial: clip
Applies to: block containers
Inherited: no
Note that CSS3 also mentions custom string value. But it has limited browser support.

text-overflow values

clipDefault. Content is clipped without ellipsis.
ellipsisContent is clipped and render an ellipsis character (three dots …)
Note that text-overflow is often used with overflow:hidden and white-space:nowrap (or white-space:pre).

Example – text-overflow clip

<style type="text/css">
.box1 {
  width: 200px;
  background-color:lightgreen;
  overflow: hidden;
  white-space:nowrap;
  text-overflow: clip;
}
</style>

<div class="box1">
Truncate without ellipsis. This is some text.
</div>
refresh done
try it online

Example – text-overflow – truncate with ellipsis

<style type="text/css">
.box1 {
  width: 200px;
  background-color:lightgreen;
  overflow: hidden;
  white-space:nowrap;
  text-overflow: ellipsis;
}
</style>

<div class="box1">
Truncate with ellipsis. This is some text.
</div>
refresh done
try it online

Related

  • CSS overflow - visible, hidden and scroll for overflowing content
  • CSS white-space - collaping and wrapping of whitespaces and newlines
  • HTML pre tag tutorial
  • CSS clip

Specification and Browser compatibility

SpecificationStatusCategories
CSS3 Text-overflowW3C Candidate RecommendationCSS3
Desktop
ChromeFirefoxIEEdgeSafariOpera
Yes 4+ Yes 7+ Yes 6+ Yes 12+ Yes 3.1+ Yes 11+
Mobile
Android ChromeAndroid FirefoxiOS SafariIE MobileOpera Mobile
Yes 47+ Yes 44+ Yes 3.2+ Yes 10+ Yes 12.1+
source: caniuse.com

Suggested posts:

  1. CSS resize – make block element resizable by user
  2. CSS text-indent – indent text in a block
  3. CSS flexbox – display flex and inline-flex
  4. CSS text-decoration – underline, overline and strikeout text
  5. CSS border-color – define color of four borders
  6. Running php eval on code with tags
  7. CSS box-shadow
  8. Edit and debug css in Chrome
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged CSS, CSS properties, Tutorials
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress