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 9090751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:26:55+00:00 2026-06-16T22:26:55+00:00

I have a div, which consists of table with different styles applied td. I

  • 0

I have a div, which consists of table with different styles applied td.

I am trying to implement a layout, if the text exceeds the width of the table td, it should go over to the next line.

But I can’t do this. My code is

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "w3.org/TR/html4/loose.dtd"> 
<html>
<head>
<title>HTML Div Overflow scrollbars</title>
<style type="text/css">
.mainDiv {
    height: 230px;
    width: 600px;
    overflow: scroll;
}
.divScroll-1 {
    width: 70%;
    white-space:nowrap;
    overflow-y: scroll;

}
.divScroll-2 {
    width: 30%;
    float:right;
     white-space:nowrap;

}

</style>
<script>
    function getText() {
        var str = document.getElementById("no").value;
        var div = document.getElementById("divScroll-1");
        var ss = document.getElementById("div33");
        var textarea = document.getElementById("mainDiv");

        if (div.innerHTML == "" ) {
            div.innerHTML += str ;
        } else {
            div.innerHTML += "</br>"  + str ;
        }

        if(ss.innerHTML == ""){
            ss.innerHTML = "Time" ;
        }else{
            ss.innerHTML  +=  "</br>"+"Time";
        }
    }
</script>
</head>
<body>
<h3>Vertical Overflow Scroll</h3>
<table align="center" width="100%" border=1>
    <tr>
        <td>
<div class="mainDiv" id="mainDiv">

<table width="100%" align="left" style="table-layout:fixed">
    <tr>
        <td height="200px" style="max-width:150px;" valign="top" class="divScroll-1" id="divScroll-1">
        </td>
        <td valign="top" class="divScroll-2" id="div33">
        </td>
    </tr>
</table>
</div>
</td></tr>
    <tr>
        <td>
<input type="text" id="no" size="20" />
<input type="button" onclick="getText()" value="Insert Text" />
</td></tr></table>
</body>
</html>

I am appending the text into the table using Javascript. If I insert a long text bigger than the width of td, remaining text will be in hidden.

I need the remaining content in to the next line.

Please give some suggestions or correct my code.

  • 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-06-16T22:26:56+00:00Added an answer on June 16, 2026 at 10:26 pm

    Try this, already on stackoverflow

    CSS: How do I wrap text with no whitespace inside a <td>?

    update your css class as follows (“divScroll-1”)

    .divScroll-1 {
         white-space: -moz-pre-wrap !important;  /* Mozilla, since 1999 */
         white-space: -pre-wrap;      /* Opera 4-6 */
         white-space: -o-pre-wrap;    /* Opera 7 */
         white-space: pre-wrap;       /* css-3 */
         word-wrap: break-word;       /* Internet Explorer 5.5+ */
         word-break: break-all;
         white-space: normal;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a div, which consists of words with different styles applied to text
I have such a table: <table> <tr> <td> My text which consists of three
I have a div which contain lots of input[type=text] fields. I want to put
I have a navigation bar which consists of php-generated html as follows: <ul> <div
I have a MenuButton which consists of a Image and a Text under the
I have a div which has width of say 200px. It does not show
I have a div which contains some text for the database: <div id=summary>Here is
this may sound simple, I have made a div block which consists of buttons
I have a layout which consists of menu on left and main content in
I have a partial view which consists of a div with a benner that

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.