472,985 Members | 2,649 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,985 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 7996
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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.