Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

This is not sizing correctly for me 1

Status
Not open for further replies.

JavaDude32

Programmer
Aug 25, 2001
180
US
This is not sizing correctly for me, the idea is:
-------------------------------------------------------
| Field1 | F2 | Field 3 |
-------------------------------------------------------
Instead the browser renders the Student Name cell as the longest cell in the table instead of allocating unused space for the Courses. Can anyone please tell me what's wrong with this:

Code:
<html>
<body>
<table width=&quot;100%&quot; height=&quot;50%&quot; border=1>
<tr>
<td width=&quot;150px&quot; height=&quot;25px&quot;>Field 1</td>
<td width=&quot;100px&quot; height=&quot;25px&quot;>F2</td>
<td width=&quot;100%&quot; height=&quot;25px&quot;>Field 3</td>
</tr>
<tr>
<td width=&quot;100%&quot; height=&quot;90%&quot;></td>
</tr>
</table>
</body>
</html>
 

You have conflicting widths for column 1, so the browser doesn't know which width to honour.

If you delete your (incidentally, erroneous) second row:

Code:
<html>
<body>
<table width=&quot;100%&quot; height=&quot;50%&quot; border=1>
<tr>
	<td width=&quot;150&quot; height=&quot;25&quot;>Field 1</td>
	<td width=&quot;100&quot; height=&quot;25&quot;>F2</td>
	<td width=&quot;100%&quot; height=&quot;25&quot;>Field 3</td>
</tr>
</table>
</body>
</html>

The browser gives more width to column 3 instead of column 1.

Of course, since you fail to mention which column represents 'Student Name' and which represents 'Courses', I cannot say if that is the desired result or not.

Hope this helps,

Dan


 
If you want to have the second row consisting of just column, you need to specifically instruct that:

<tr>
<td colspan=&quot;3&quot;>Contents</td>
</tr>

Which means that the cell in the second row should span across three columns.
 
I think another problem is that you were confusing CSS-style width specification, where you have to specify a unit, and HTML-style where you don't specify one (it's either pixels or %). So these are equivalent:
[tt]
<td width=&quot;100&quot;>
<td style=&quot;width:100px&quot;>
[/tt]
This is invalid, though I think most browsers will interpret it as 100 pixels:
[tt]
<td style=&quot;width:100&quot;>
[/tt]
And this is invalid syntax which will be ignored (because &quot;100px&quot; is neither an integer or a percentage):
[tt]
<td width=&quot;100px&quot;>
[/tt]

-- Chris Hunt
 
Thanks very much, I made the error of believing that tables were more dynamic.

What I had expected was the ability of one to be able to just define whatever column specs such as having the first row be independent of the second row.

-----------------------------
| F11 | F21 | F31 |
-----------------------------
| F12 | F22 |
| | |
-----------------------------

I now know that is not the case. However, this isn't a problem as the columns should be the same width independent of the row, thanks a lot.

------------------
| F1 | F2 | F3 |
------------------
| F1 | F2 | F3 |
------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top