
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
What is to be done when text overflows the containing element with JavaScript?
Use the textOverflow property to counter the text overflow issue. Add ellipses if the text overflows the containing element.
Example
You can try to run the following code to learn what is to be done when text overflows the containing element with JavaScript −
<!DOCTYPE html> <html> <head> <style> #myID { border: 2px solid blue; background-color: gray; overflow: hidden; text-overflow: visible; width: 200px; white-space: nowrap; } </style> </head> <body> <button onclick = "display()"> Click </button> <div id = "myID"> This is Demo Text! This is Demo Text! This is Demo Text!<br> This is Demo Text! This is Demo Text! This is Demo Text!<br> This is Demo Text! This is Demo Text! This is Demo Text!<br> This is Demo Text! This is Demo Text! This is Demo Text!<br> </div> <script> function display() { document.getElementById("myID").style.textOverflow = "ellipsis"; } </script> </body> </html>
- Related Articles
- What is to be done when MongoDB takes too much time to find the record?
- How to set whether the text of an element can be selected or not with JavaScript?
- What should be done with the left/ right edges of the content on overflow with JavaScript?
- Replace HTML div into text element with JavaScript?
- Why milk in a saucepan overflows when heated?
- How to preserve the readability of text when font fallback occurs with JavaScript?
- Set whether the text of the element can be selected or not with CSS
- What can be done to control water pollution?
- What is the use of jsp text action element?
- Why the process of crystallisation is needed to be done?
- JavaScript - Get the text of a span element
- How can element wise multiplication be done in Tensorflow using Python?
- How to Create a Comment Box with a Containing Text Using CSS
- Using XPATH to search text containing  
- Is it possible to select text boxes with JavaScript?

Advertisements