473,387 Members | 1,641 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,387 software developers and data experts.

TD tags are wider than necessary

I have made a UserControl that contains the navigation for my site. However,
the table cell that I am putting it in is taking up more width than
necessary, therefore leaving extra whitespace on my pages. I have tried
everything I can think of to get rid of this problem, but it still remains.
Any ideas? My basic table layout is as follows:

<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"></td>
</tr>
<tr valign="top">
<td rowspan="2">THIS IS WHERE MY USERCONTROL IS</td>
<td align="center" width="*"></td>
</tr>
<tr>
<td align="center" valign="top">
THIS IS MY CONTENT AREA
</td>
</tr>
</table>

Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Apr 23 '07 #1
4 1553
I have read that the column widths for a table are determined by the values
specified in the first row. Is this true? If it is, I have the following
problem. In my table layout (which you can see in my original posting) the
first row is multi-column, which obviously prevents me from specifying the
column widths. If what I read is the reason for my problem, how can I fix
it? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:On**************@TK2MSFTNGP02.phx.gbl...
>I have made a UserControl that contains the navigation for my site.
However, the table cell that I am putting it in is taking up more width
than necessary, therefore leaving extra whitespace on my pages. I have
tried everything I can think of to get rid of this problem, but it still
remains. Any ideas? My basic table layout is as follows:

<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"></td>
</tr>
<tr valign="top">
<td rowspan="2">THIS IS WHERE MY USERCONTROL IS</td>
<td align="center" width="*"></td>
</tr>
<tr>
<td align="center" valign="top">
THIS IS MY CONTENT AREA
</td>
</tr>
</table>

Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Apr 24 '07 #2
On Apr 24, 1:12 am, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
I have read that the column widths for a table are determined by the values
specified in the first row. Is this true? If it is, I have the following
problem. In my table layout (which you can see in my original posting) the
first row is multi-column, which obviously prevents me from specifying the
column widths. If what I read is the reason for my problem, how can I fix
it? Thanks.
--
I've got the following to work:

<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr valign="top">
<td rowspan="2">THIS IS WHERE MY USERCONTROL IS</td>
<td align="center" width="100%">&nbsp;</td>
</tr>
<tr>
<td align="center" valign="top">
THIS IS MY CONTENT AREA
</td>
</tr>
</table>

But it depends on what markup your usercontrol actually creates.

Damien

Apr 24 '07 #3
Hi Damien,

Basically, the browser interprets the HTML procedurally. So, if your table
is set to 100% width, and the top row has a colspan of the entire table (2
in this case), the first column in a row that doesn't span the entire table
will be used, or the second row in this case. Take a look at the following:

<table style="width:100%; border-collapse: collapse;">
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td rowspan="2" style="width: 300px">THIS IS WHERE MY USERCONTROL
IS</td>
<td style="text-align:center;">&nbsp;</td>
</tr>
<tr>
<td style="text-align:center; vertical-align:top">
THIS IS MY CONTENT AREA
</td>
</tr>
</table>

A couple of notes: Since the width of the table is defined, and the width of
the first column is defined, the width of the second column does not need to
be defined, as it will fill out the remaining part of the table. Also, note
that I have substituted the use of CSS styles for those attributes that they
replace. This is conformant with XHTML, and will work better in browsers
overall. In addition, CSS can be defined outside the table, making the
(X)HTML code for the table much more readable, and easier to tweak, as the
style can be defined by itself, as in the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 1</title>
<style type="text/css">
table
{
width: 100%;
border-collapse: collapse;
}
table td{
vertical-align:top;
}
table td.leftPanel
{
width: 3000px;
}
table td.content
{
text-align: center;
}
</style>
</head>

<body>
<table>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td rowspan="2" class="leftPanel">THIS IS WHERE MY USERCONTROL IS</td>
<td class="content">&nbsp;</td>
</tr>
<tr>
<td class="content">
THIS IS MY CONTENT AREA
</td>
</tr>
</table>
</body>

</html>

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
"Damien" <Da*******************@hotmail.comwrote in message
news:11**********************@c18g2000prb.googlegr oups.com...
On Apr 24, 1:12 am, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
>I have read that the column widths for a table are determined by the
values
specified in the first row. Is this true? If it is, I have the following
problem. In my table layout (which you can see in my original posting)
the
first row is multi-column, which obviously prevents me from specifying
the
column widths. If what I read is the reason for my problem, how can I fix
it? Thanks.
--

I've got the following to work:

<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr valign="top">
<td rowspan="2">THIS IS WHERE MY USERCONTROL IS</td>
<td align="center" width="100%">&nbsp;</td>
</tr>
<tr>
<td align="center" valign="top">
THIS IS MY CONTENT AREA
</td>
</tr>
</table>

But it depends on what markup your usercontrol actually creates.

Damien

Apr 24 '07 #4
That worked great! However, I am now having a similar problem with the
heights of the second column. I want the height of the second cell in the
second row to be the minimum possible, but I am having trouble doing this. I
tried something similar to what you did for the width situation, but I think
this is different because it is height. Any ideas? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Damien" <Da*******************@hotmail.comwrote in message
news:11**********************@c18g2000prb.googlegr oups.com...
On Apr 24, 1:12 am, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
>I have read that the column widths for a table are determined by the
values
specified in the first row. Is this true? If it is, I have the following
problem. In my table layout (which you can see in my original posting)
the
first row is multi-column, which obviously prevents me from specifying
the
column widths. If what I read is the reason for my problem, how can I fix
it? Thanks.
--

I've got the following to work:

<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr valign="top">
<td rowspan="2">THIS IS WHERE MY USERCONTROL IS</td>
<td align="center" width="100%">&nbsp;</td>
</tr>
<tr>
<td align="center" valign="top">
THIS IS MY CONTENT AREA
</td>
</tr>
</table>

But it depends on what markup your usercontrol actually creates.

Damien

Apr 25 '07 #5

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

Similar topics

4
by: Luke Dalessandro | last post by:
I have some XML data that has mixed content XML tags that embed XHTML tags, for instance: <note>Somebody wrote this note in XHTML and wanto to <a href="link.html" target="_new">link</a> to a...
19
by: Christian Hvid | last post by:
Hello groups. I have a series of applet computer games on my homepage: http://vredungmand.dk/games/erik-spillet/index.html http://vredungmand.dk/games/nohats/index.html...
24
by: Day Bird Loft | last post by:
Web Authoring | Meta-Tags The first thing to understand in regard to Meta Tags is the three most important tags placed in the head of your html documents. They are the title, description, and...
8
by: Will Pittenger | last post by:
I have a Windows program C# .NET solution where when I update its XML documentation, some tags are not recognized and turned into the corresponding HTML. Those tags include <c>, <code>, <para>,...
7
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no...
2
by: TS | last post by:
If I want a textbox to be wide enough to hold only 2 characters and I set the columns=2, the textbox ends up being much wider than is necessary. I would guess that it is as wide as the 2 widest...
10
by: Andy Fish | last post by:
Hi, I would like to include extra "hidden" information in a generated HTML page that can be used by javascript functions. I realise that most browsers seem to ignore any tags and attributes...
5
by: divina11 | last post by:
is it always necessary to close these tags? by using </br>
0
by: PromisedOyster | last post by:
I have a datagridview. One of the database bound columns shows a code. However, when I drop down this combo, I would like to see a code + description as this may help the user select the...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.