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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:25:43+00:00 2026-06-07T10:25:43+00:00

I would like the long code to wrap around inside the td and div.

  • 0

I would like the long code to wrap around inside the td and div. It does so in Chrome, but I can’t get it to work in Firefox. In Firefox, the text just keeps going into the next td element. Could someone help me out? Other comments on my code are welcome too (e.g. “don’t use so many divs” or something)

<tr class="line">
        <td class="lineNumber">38</td>
        <td class="code"><div class="divCode"><code>    error = guess - n/guessjfdklsjf dklsjf kdlsjfkldsjfkl dsjfklds jfkldsjfkljdsa;lfkjdsakl;fjdskla;fjdksl;ajfkld;sajfkl;dsajfkl;dsa
                    <td class="otherClass">other stuff here</td>

</code></div></td>
</tr>

This is styled by the following CSS:

.line td{  
padding-right: 10px;  
    padding-left: 10px;  
    font-family: monospace;  
    word-wrap: break-word;  
    max-width: 40ex;
}  

.code {
    white-space: pre;
    max-width: 40ex;
}

.divCode {
    max-width: 40ex;
}

code {
    max-width: 40ex;
    word-wrap:break-word;
}

Thanks,
–h

  • 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-07T10:25:45+00:00Added an answer on June 7, 2026 at 10:25 am

    The declaration white-space: pre prevents wrapping, so removing it fixes this problem. But if you wish to preserve spaces in the content, use white-space: pre-wrap instead (Caveat: no support in IE 7).

    Note that wrapping does not preserve indentation: if a line starts with spaces and gets wrapped, the next line starts in the first position, with no indentation. To get wrapping that preserves indentation (and possibly indents continuation lines more than the initial line), you need different markup: make each logical line an element etc.

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

Sidebar

Related Questions

I would like to work with very long Strings in Eclipse. So my Problem
I would like to know a way can detect on how long the mouse
Does anyone know of a way to get vim to wrap long lines of
I would like to get the zip code of the current location in android
i would like to make my code easier to read by replacing long paths
I would like to know if some one can improve my code... Using jQuery
i would like to process an undefinitely long string in C++ by chunks of
I would like to determine what the long url of a short url is.
I would like to show a small clip from a long video file that
I would like to change the entity property from String to long. I have

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.