Eduardo Aviles
asked on
HTML Cell Alignment with nested Table
Hello Experts, I am hoping you can help with my dilemma. I have an HTML page that has two tables one table nested to the other. What I need to do is align the cell width of the second table to match with the first one. I have tried everything to get it to work with no success. Any help would be most appreciated.
Code:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatibl e" content="IE=10">
<meta name="viewport" content="width=device-widt h, initial-scale=1">
<style>
/* Create two equal columns that floats next to each other */
.middle {
width: 900px;
padding: 10px;
border: solid;
margin-left: auto;
margin-right: auto;
}
</style>
</head>
<body bgcolor = "#86888c" text="Black">
<div class="middle" style="background-color:#3 399ff;" >
<p>
<b><center><font size="3">
Testing <br>
Request<br>
<font size="2" color = "Red">Version 5.0 - Development</font>
</center></b></font>
</p>
<table border="1" id="content" style="width:100%" >
<tr>
<td style="padding-left: 10px" style="font-size: 12pt">Number:</td>
<td style="padding-left: 10px" style="font-size: 12pt">
<input type="text" style="width:150px;" name = "RequestNum" size="20" title="" id="RequestNum" disabled/><i><font size="2">
</td>
<td style="padding-left: 10px" style="font-size: 12pt">Title:</td>
<td><input type="text" style="width:200px;" id="DocTitle" name = "DocTitle" title="" color="black" rows="2" cols="50" maxlength="30" style="width:150px;">
</td>
</tr>
<tr>
<td style="padding-left: 10px" style="font-size: 12pt">Doc Number:</td>
<td style="padding-left: 10px" style="font-size: 12pt"><input type="text" class="doc" style="width:150px;" id="docNum0"/></td>
<td style="padding-left: 10px" style="font-size: 12pt" >Doc Rev: </td>
<td><input type="text" class="rev" style="width:40px;" id="rev0"> <input type="button" id="more_fields" onclick="add_fields();" value="+" /></td>
</tr>
</table>
<table border="1" style="width:100%">
<tr>
<td style="padding-left: 10px">Program:</td>
<td style="padding-left: 10px">
<Select name="Program" title="" style="width:150px;" id="Program">
<option value="" selected>- Select -</option>
<option value="Test1">Stress</opti on>
<option value="Test2">Test</option >
</Select>
</td>
<td style="padding-left: 10px">Creation Date:</td>
<td>
<input type ="CrDateCalc" name= "CrDateCalc" id="CrDateCalc" size="20" style="width:150px;" title="" readonly/>
</td>
</tr>
<tr>
<td colspan="100%">
<hr></hr>
</td>
</tr>
<tr>
<td colspan="2" style="font-size: 12pt"/>Testing Together:
<Select id="" name="" title="">
<option value="No">No</option>
<option value="Yes">Yes</option>
</Select>
</td>
</tr>
<tr>
</tr>
</body>
</div>
</html>
Code:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatibl
<meta name="viewport" content="width=device-widt
<style>
/* Create two equal columns that floats next to each other */
.middle {
width: 900px;
padding: 10px;
border: solid;
margin-left: auto;
margin-right: auto;
}
</style>
</head>
<body bgcolor = "#86888c" text="Black">
<div class="middle" style="background-color:#3
<p>
<b><center><font size="3">
Testing <br>
Request<br>
<font size="2" color = "Red">Version 5.0 - Development</font>
</center></b></font>
</p>
<table border="1" id="content" style="width:100%" >
<tr>
<td style="padding-left: 10px" style="font-size: 12pt">Number:</td>
<td style="padding-left: 10px" style="font-size: 12pt">
<input type="text" style="width:150px;" name = "RequestNum" size="20" title="" id="RequestNum" disabled/><i><font size="2">
</td>
<td style="padding-left: 10px" style="font-size: 12pt">Title:</td>
<td><input type="text" style="width:200px;" id="DocTitle" name = "DocTitle" title="" color="black" rows="2" cols="50" maxlength="30" style="width:150px;">
</td>
</tr>
<tr>
<td style="padding-left: 10px" style="font-size: 12pt">Doc Number:</td>
<td style="padding-left: 10px" style="font-size: 12pt"><input type="text" class="doc" style="width:150px;" id="docNum0"/></td>
<td style="padding-left: 10px" style="font-size: 12pt" >Doc Rev: </td>
<td><input type="text" class="rev" style="width:40px;" id="rev0"> <input type="button" id="more_fields" onclick="add_fields();" value="+" /></td>
</tr>
</table>
<table border="1" style="width:100%">
<tr>
<td style="padding-left: 10px">Program:</td>
<td style="padding-left: 10px">
<Select name="Program" title="" style="width:150px;" id="Program">
<option value="" selected>- Select -</option>
<option value="Test1">Stress</opti
<option value="Test2">Test</option
</Select>
</td>
<td style="padding-left: 10px">Creation Date:</td>
<td>
<input type ="CrDateCalc" name= "CrDateCalc" id="CrDateCalc" size="20" style="width:150px;" title="" readonly/>
</td>
</tr>
<tr>
<td colspan="100%">
<hr></hr>
</td>
</tr>
<tr>
<td colspan="2" style="font-size: 12pt"/>Testing Together:
<Select id="" name="" title="">
<option value="No">No</option>
<option value="Yes">Yes</option>
</Select>
</td>
</tr>
<tr>
</tr>
</body>
</div>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
First don't place a form in table this is not a good practice, use DIV instead.
Also don't use inline CSS this is not a good practice, use external .css file with class.
You will see this is simpler to work and adapt the CSS and you will have uptodate code (not old fashion)...
First don't place a form in table this is not a good practice, use DIV instead.
Also don't use inline CSS this is not a good practice, use external .css file with class.
You will see this is simpler to work and adapt the CSS and you will have uptodate code (not old fashion)...
First don't place a form in table this is not a good practice, use DIV instead
A form is not allowed to be a child element of a table or tbody or tr.
In fact, I can't see any form inside the posted HTML, the current structure is valid and if the author wants a form then he can use it around the entire table that will not affect the correctness of the code.
You can have an entire table inside a form and you can have a form inside a table cell but you cannot have part of a table inside a form.
Basically, it's not a good idea to it this way.
Else you need to set the same width for the TD's of both tables using classes or direct style, IMO using the percent % width will be more efficient in this case.
Working live fiddle