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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:05:07+00:00 2026-06-13T18:05:07+00:00

I was recently trying to figure out how to make a cell/column fit it’s

  • 0

I was recently trying to figure out how to make a cell/column fit it’s width to it’s content. I found a question on stackoverflow that seemed to perfectly fit the bill for what I was looking for: How to make width of a column fit to its contents in HTML table?

My issue was when I added a space to the content of the cell, it added a return and bumps the next word down a line.

So this code:

<div style="max-width:700px;">
<table border="1">

    <tr><td width="1px">Papua New Guinea:</td><td >Goroka</td></tr>
    <tr><td colSpan="2">this is a loooooooooooooooong text</td></tr>
</table>

Produces this table:

http://cl&zwj;.ly/image/2F0V1J3V2u22

Instead, this is what I was wanting:

http://cl&zwj;.ly/image/2m0a0m0t0L0v

I realize that putting &nbsp; in instead of spaces would fix this. My issue is that this is being used in a mail newsletter template, and the text in that cell is dynamic. Sometimes there are spaces, sometimes not. For example yesterday it said Bolivia, today Papua New Guinea which is when I noticed the problem.

  • 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-13T18:05:09+00:00Added an answer on June 13, 2026 at 6:05 pm

    Did you try

    td {
        white-space: nowrap;
    }
    

    http://jsfiddle.net/QkNqk/

    You can also use

    td {
        white-space: pre;
    }
    

    To let newlines in the source create breaks. So as long as you don’t have a line break,the text will stay in one line

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

Sidebar

Related Questions

I recently found the google maps-styling(https://developers.google.com/maps/documentation/javascript/styling) I've been trying to figure out how to
I'm trying to figure out if I should start using the recently added object
For some reason that I've been trying to figure out, the links on my
I've recently been trying to figure out how to get PyCrypto to recognize PEM's
I recently started using d3js and I am currently trying to figure out how
I've recently started learning/using django; I'm trying to figure out a way to have
I've recently been trying to figure out a way to get parameterized queries to
I was recently trying to figure out the fastest way to compare two large
I recently started playing around with Apache Solr and currently trying to figure out
I have been recently trying to deploy a C# application on a computer 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.