473,382 Members | 1,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Smallest Possible <TD> width values

Hi everyone

Sorry to ask such a simple question. I created a table with 18 columns-
16 of which represent weeks starting from 1 to 16. In each cell I have
a field which takes either a Null value or and "X". Since I only have
at most one (1)character, I would like to make the td with as small as
possible. I have placed width="5px" but it does seem to work. Can
anyone suggest how I can make the cell smaller?

Thanks

Jul 24 '05 #1
8 8161
ef*****@epitome.com.sg writes:
Sorry to ask such a simple question. I created a table with 18 columns-
16 of which represent weeks starting from 1 to 16. In each cell I have
a field which takes either a Null value or and "X". Since I only have
at most one (1)character, I would like to make the td with as small as
possible. I have placed width="5px" but it does seem to work. Can
anyone suggest how I can make the cell smaller?


1) You mean width="5" or style="width: 5px;" for something that will
do something.

2) Actually, neither of those does what you actually want, which is
for the table cell to shrink as small as possible while still
containing the data. If someone's using a large font, then 5px
won't be anything like enough room to contain the 'X'.

3) Fortunately, *provided* that there's nothing else in the table (for
example, a width attribute on the <table> tag) to make it wider,
columns only take up the minimum space needed.

So, the following should work.
<table>
....
<tr>...<td>X</td><td>X</td><td></td>...</tr>
....
</table>

Can you post the URL of the page the table is on?

--
Chris
Jul 24 '05 #2
ef*****@epitome.com.sg wrote:
Hi everyone

Sorry to ask such a simple question. I created a table with 18 columns-
16 of which represent weeks starting from 1 to 16. In each cell I have
a field which takes either a Null value or and "X". Since I only have
at most one (1)character, I would like to make the td with as small as
possible. I have placed width="5px" but it does seem to work. Can
anyone suggest how I can make the cell smaller?


Depends on what 'works' means. Set the width to 1em and center
align the text. If the numbers get bigger, you may need to use 2en or
similar:

<style type="text/css">
td {border: 1px solid blue; width: 1em; text-align:center;}
</style>

<table>
<tr>
<td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td>
<td>7</td><td>8</td><td>9</td><td>10</td><td>11</td>
<td>12</td><td>13</td><td>14</td><td>15</td><td>16</td>
</tr>
<tr>
<td>x</td><td>&nbsp;</td><td>x</td><td>x</td><td>x</td><td>x</td>
<td>&nbsp;</td><td>x</td><td>x</td><td>&nbsp;</td><td>x</td>
<td>x</td><td>&nbsp;</td><td>x</td><td>&nbsp;</td><td>x</td>
</tr>
</table>

--
Rob
Jul 24 '05 #3
ef*****@epitome.com.sg wrote:
Sorry to ask such a simple question. I created a table with 18 columns-
16 of which represent weeks starting from 1 to 16. In each cell I have
a field which takes either a Null value or and "X". Since I only have
at most one (1)character, I would like to make the td with as small as
possible.
That will happen automatically, unless you've specified a width for
the overall table that is smaller than the width of the sum of the
cells.
I have placed width="5px" but it does seem to work.
Is that meant to be HTML or CSS?

In HTML you would use width="5" and in CSS you would use width: 5px;.
In both cases the widths will be ignored if (a) the cells need to be
wider because the contents are wider or (b) the table has a width set
that means that the cells must be wider in order to add up to the
table width.
Can anyone suggest how I can make the cell smaller?


Stop trying. Unless you do something to stop them tables normally
shrink to the smallest possible size. If you still have problems post
the URL so we can see if anything else on the page is interfering.

Steve
--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 24 '05 #4

<ef*****@epitome.com.sg> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi everyone

Sorry to ask such a simple question. I created a table with 18 columns-
16 of which represent weeks starting from 1 to 16. In each cell I have
a field which takes either a Null value or and "X". Since I only have
at most one (1)character, I would like to make the td with as small as
possible. I have placed width="5px" but it does seem to work. Can
anyone suggest how I can make the cell smaller?

Thanks


Do not use the width attribute at all for a <td>. The cell will shrink to
the size of the "X". But if your two digit numbers for the weeks are in
that same table, then you won't have just one character per cell.

IE does something weird, though. Your closing TD tag must be on the same
line as the opening TD tag. If it is moved down a line or so, it makes the
height larger than what you want. Not always, though. It's a quirk of IE, I
believe. I've read about it several times on developer's websites.

Also, a cell containing a transparent .gif can make it shrink even more.
I've had TD colspans set to null in which I couldn't get them to shrink
below what appeared to be 10 pixels in height. But after placing a
transparent gif set to the height I wanted, say 5-7 pixels, in the cell, the
colspan shrunk in height.

When you set your table border to "1", is the border close to your "X" on
all sides? It should be. I assume you have cellpadding & cellspacing set to
zero.

Carla
Jul 24 '05 #5
Chris Morris <c.********@durham.ac.uk> wrote:
1) You mean width="5" or style="width: 5px;" for something that
will do something.
Those are the syntactically correct ways, but in practice browsers will
eat width="5px" (they basically ignore what comes after the number).
2) Actually, neither of those does what you actually want, which is
for the table cell to shrink as small as possible while still
containing the data. If someone's using a large font, then 5px
won't be anything like enough room to contain the 'X'.
There would be problems even with small fonts, since 5px is really
small.
3) Fortunately, *provided* that there's nothing else in the table
(for
example, a width attribute on the <table> tag) to make it wider,
columns only take up the minimum space needed.


Yes, but that includes cell padding, which is nonzero by default, and
by default there's also spacing between cells. You can use
<table cellpadding="0" cellspacing="0">
but it's actually easier to use CSS, where you could also set padding
for cells as you like (e.g., top and bottom padding but no horizontal
padding). E.g.

table { border-collapse: collapse; }
td { padding: 0; /* or e.g. padding: 2px 0; */ }

Then there's the question how accessible the table is. How would it
work in speech synthesis?

(And there's also the question whether "X" or "x" is really a suitable
character. You don't really mean the letter of the Latin alphabet but
an x-like mark, which could perhaps be identified with U+2717 BALLOT X.
However, using &#x2717; is probably not a feasible option at present,
since few fonts contain it.)

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 24 '05 #6

Jukka K. Korpela wrote:
Chris Morris <c.********@durham.ac.uk> wrote:
1) You mean width="5" or style="width: 5px;" for something that
will do something.
Those are the syntactically correct ways, but in practice browsers

will eat width="5px" (they basically ignore what comes after the number).
2) Actually, neither of those does what you actually want, which is
for the table cell to shrink as small as possible while still
containing the data. If someone's using a large font, then 5px
won't be anything like enough room to contain the 'X'.
There would be problems even with small fonts, since 5px is really
small.
3) Fortunately, *provided* that there's nothing else in the table
(for
example, a width attribute on the <table> tag) to make it wider,
columns only take up the minimum space needed.


Yes, but that includes cell padding, which is nonzero by default, and

by default there's also spacing between cells. You can use
<table cellpadding="0" cellspacing="0">
but it's actually easier to use CSS, where you could also set padding for cells as you like (e.g., top and bottom padding but no horizontal padding). E.g.

table { border-collapse: collapse; }
td { padding: 0; /* or e.g. padding: 2px 0; */ }

Then there's the question how accessible the table is. How would it
work in speech synthesis?

(And there's also the question whether "X" or "x" is really a suitable character. You don't really mean the letter of the Latin alphabet but an x-like mark, which could perhaps be identified with U+2717 BALLOT X. However, using &#x2717; is probably not a feasible option at present,
since few fonts contain it.)

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


Thanks every one. My table actually need to have a width of 770. I want
my first two columns to be 200 and the other 16 to take the rest
evenly. I removed all td width attributes and so far is seems to take
up more space 770 horizontally.

I will try a few other variation.

Jul 24 '05 #7
ef*****@epitome.com.sg wrote:
Thanks every one.
Please learn to trim quotations if you need further help some day.
My table actually need to have a width of 770.
No it doesn't. You have wrong design, and _you_ try to force the width
to 770 (thereby virtually guaranteeing that printing the page will
result in frustration, among other things).
I want my first two columns to be 200 and the other 16 to take the
rest evenly. I removed all td width attributes and so far is seems
to take up more space 770 horizontally.
This does not parse. Do you mean _more than_ 770 (pixels)?
I will try a few other variation.


You might need to redesign the page. Or maybe _design_ it for the first
time, since this sounds you are just randomly trying different things.
Sorry, can't give more details in the absence of any info on what you
are really trying to achiee.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 24 '05 #8

Jukka K. Korpela wrote:
ef*****@epitome.com.sg wrote:
Thanks every one.
Please learn to trim quotations if you need further help some day.
My table actually need to have a width of 770.


No it doesn't. You have wrong design, and _you_ try to force the

width to 770 (thereby virtually guaranteeing that printing the page will
result in frustration, among other things).
I want my first two columns to be 200 and the other 16 to take the
rest evenly. I removed all td width attributes and so far is seems
to take up more space 770 horizontally.
This does not parse. Do you mean _more than_ 770 (pixels)?
I will try a few other variation.


You might need to redesign the page. Or maybe _design_ it for the

first time, since this sounds you are just randomly trying different things. Sorry, can't give more details in the absence of any info on what you are really trying to achiee.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


Thanks everyone. I solved it.

This is what I did. I set the table width to be 770.
on the first row. I merged the first two columns, and merged the other
sixteen columns.

In the properties of the first merged column, I set the width property
to be "350" (width="350"). In the properties of the second column, I
set width="100%".

What this does is it ensured the first 2 columns take up 350 px and the
rest 520 pixels is spread evenly among the 16 columns. This made the
column as small as it needed to be. If I wanted it smaller. I just make
the width of the first two columns wider.

Jul 24 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: bissatch | last post by:
Hi, I am trying to use JavaScript to write a table column on a web page. The code is as follows: <html> <head> <script> function displaycount() {
3
by: RC | last post by:
I have a very sime html table like <html><head><title>My Table</title> <style> input { margin: 0; padding: 0; border-width: 0; text-indet: 0; text-align: left } </style></head><body> <table...
3
by: RC | last post by:
I have a very sime html table like <html><head><title>My Table</title> <style> input { margin: 0; padding: 0; border-width: 0; text-indet: 0; text-align: left } </style></head><body> <table...
3
by: RC | last post by:
I have a very sime html table like <html><head><title>My Table</title> <style> input { margin: 0; padding: 0; border-width: 0; text-indet: 0; text-align: left } </style></head><body> <table...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.