Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Changing the width of table cells

Featured Replies

Hi,

 

I'm now looking into creating a login page for my website, but I'm having trouble getting the table cells to look how I want them to.

 

I'm using this code at the mo:

 

	<div id="client-login-table">
<table width="250" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="20">
<tr>
</tr>
<tr>
<td width="300"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td><input name="mypassword" type="text" id="mypassword"></td>
</tr>
<tr>
<td><input type="image" src="images/submit.png" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
</div>
</div>	

 

I've tried changing all of the width values and adding some other attributes but nothing works. Thanks for any help

Hi,

 

I'm now looking into creating a login page for my website, but I'm having trouble getting the table cells to look how I want them to.

 

I'm using this code at the mo:

 

	<div id="client-login-table">
<table width="250" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="20">
<tr>
</tr>
<tr>
<td width="300"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td><input name="mypassword" type="text" id="mypassword"></td>
</tr>
<tr>
<td><input type="image" src="images/submit.png" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
</div>
</div>	

 

I've tried changing all of the width values and adding some other attributes but nothing works. Thanks for any help

 

looks to me your missing out the px

 

example 250px, or % like on your code one is set at 100%

Your main table is 250px wide, then the inner table in the form is 100% wide which is OK, but then you have a td tag which is 300px wide - too wide.

 

I think I would put the form inside the td tag, not between a tr tag and a td tag.

 

<div id="client-login-table">
<table width="500" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>

<td>
<form name="form1" method="post" action="checklogin.php">
<table width="100%" border="0" cellpadding="3" cellspacing="20">
<tr>
</tr>
<tr>
<td width="300"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td><input name="mypassword" type="text" id="mypassword"></td>
</tr>
<tr>
<td><input type="image" src="images/submit.png" name="Submit" value="Login"></td>
</tr>
</table>
</form>
</td>

</tr>
</table>
</div>
</div>	

  • Author

Oops I didnt realise I left that value as 300, I must of changed that when I was playing with it.

 

Anyway, i've fixed my own problem now..i didnt realise that you had to use the attribute 'size' for the input area, i was trying to use width.

 

I changed this:

 

  <td width="300"><input name="myusername" type="text" id="myusername"></td>

 

To this:

 

	<td width="300" ><input name="myusername" type="text" id="myusername" size="25"></td>

 

and its OK now. Thanks for the fast replies anyway :)

so you meant the area you put text - username/password not the table surrounding it.

  • Author

Yeah, sorry for being confusing. I've never used tables before so getting used to them still.

no need to be sorry, we all make mistakes and we all learning no matter what level we are at, we can all make the smallest of mistakes, iv had experts tell me somethings not possible when it is :spiteful:

I changed this:

 

  <td width="300"><input name="myusername" type="text" id="myusername"></td>

 

To this:

 

	<td width="300" ><input name="myusername" type="text" id="myusername" size="25"></td>

 

You can use width or size for the input tag and other form tags, in fact it's often more accurate because some browsers like Safari seem to make the "size" a different number of pixels, so you could have:-

<td><input style="width: 300px;" name="myusername" type="text" id="myusername"></td>

 

where the width is for the input tag, not the td tag.

 

(or give a class to the input tag with the width in a stylesheet).

  • Author

You can use width or size for the input tag and other form tags, in fact it's often more accurate because some browsers like Safari seem to make the "size" a different number of pixels, so you could have:-

<td><input style="width: 300px;" name="myusername" type="text" id="myusername"></td>

 

where the width is for the input tag, not the td tag.

 

(or give a class to the input tag with the width in a stylesheet).

 

Ahh I understand now, I didn't use the 'style' part as well. I'm gonna stick with what I've got at the moment because this is only a practise website but I'll use your input in the future, thanks!

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.