Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6780915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:33:44+00:00 2026-05-26T16:33:44+00:00

Quick disclaimer: I saw some plugins that truncate text strings but they do not

  • 0

Quick disclaimer: I saw some plugins that truncate text strings but they do not do it the way I need it…

I need to truncate the text by limiting the space allocated to it. For example, if i have a block of text and it is placed in a div that has dimensions preventing entire text to be shown, I’ like to show as much as possible and then append helix at the end of the string.

I think I can use overflow:hidden, but how do I add “…”? Also, is it possible to determine if the text needs more space than the area provide?

<div style="width: 300px; height: 100px; border: 1px solid #ccc; overflow:hidden">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis facilisis risus vel mi placerat ut bibendum dui tempus. In dictum quam eu sem condimentum elementum. Cras id urna eget turpis feugiat porttitor. In hac habitasse platea dictumst. Cras tincidunt risus id sapien sagittis feugiat interdum orci adipiscing. Sed venenatis neque nec nibh mattis laoreet. In ut sapien in felis posuere feugiat. Nulla vulputate, augue nec elementum volutpat, justo nisl vulputate tellus, eget blandit lectus enim at ante. Donec posuere augue a orci sollicitudin ut imperdiet ante varius. 
</div>

DEMO

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:33:45+00:00Added an answer on May 26, 2026 at 4:33 pm

    First here is a post on how to find the width of text in a div: Calculating text width

    Once you have this width you could take the percentage of how wide your wrapping div is compared to the text width.

    Then you could split your text into an array of chars and take the percentage above and apply it to that array to get your estimated desired text length.

    something like this jsfiddle

    http://jsfiddle.net/RGybB/

    Update to show how percentage is calculated

    http://jsfiddle.net/RGybB/2/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Quick one, but thought I'd ask. Is there a better way of getting the
Quick question. There is a legacy website (that is not under my control and
Quick question here: why not ALWAYS use ArrayLists in Java? They apparently have equal
Quick one; I doubt it's possible, but is there any way to take advantage
Quick question - but I wondered what is the neatest way to achieve the
Quick question. What do you think, I have a few sites that use a
Quick question regarding CSS and the browser. I tried searching SO and found some
Quick (and hopefully easy) question: I need to trigger a download of a PDF
Quick one for you guys. Say I have a function that outputs a string:
Quick question playing with PL SQL it seems that the tables column was named

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.