How to make input elements line up? - html

my form I'm working on the Free Code Camp Product Landing page Project. I'm close to finishing, and one of the last things I want to add is a 2 column form. I've lined up the label elements, but it looks really ugly as the input elements are not lined up and I can't think of a way to position them in the way that I want.
``HTML
<!-- Order Section -->
<div id="order-wrapper">
<section id="order-section">
<h2>Order</h2>
<form id="order-form">
<label class="order-box">Product Name
<input>
</label>
<label class="order-box">Quantity
<input>
</label>
<label class="order-box">First Name
<input>
</label>
<label class="order-box">Last Name
<input>
</label>
<label class="order-box">E-mail
<input>
</label class="order-box">
<label>Phone Number
<input>
</label>
<label class="order-box">Street Address
<input>
</label>
</form>
</section>
</div>
<!-- End Order Section -->
/* Order Section */
#order-wrapper{
background-color: rgba(245, 202, 195, 1);
height: 40rem;
}
#order-form{
width: 100%;
}
#order-form label{
display: inline-block;
width: 25%;
margin-left: 20%;
margin-top: 4%;
}
#order-form input{
width: 60%;
margin-left: 5%;
}
#order-section h2{
font-family:'Homemade Apple', cursive;
font-size:2rem ;
font-weight: 500;
text-align: center;
padding-top: 2%;
margin-top: 0.8%;
}
/* End Order Section */

Not sure if this is the style you were going for, you can use tables.
HTML
<div id="order-wrapper">
<section id="order-section">
<h2>Order</h2>
<form id="order-form">
<table style="list-style: none;">
<tr>
<td><label class="order-box">Product Name</label></td>
<td><input></td>
</tr>
<tr>
<td><label class="order-box">Quantity</label></td>
<td><input></td>
</tr>
<tr>
<td><label class="order-box">FIrst Name</label></td>
<td><input></td>
</tr>
<tr>
<td><label class="order-box">Last Name</label></td>
<td><input></td>
</tr>
<tr>
<td><label class="order-box">Email</label></td>
<td><input></td>
</tr>
<tr>
<td><label class="order-box">Phone Number</label></td>
<td><input></td>
</tr>
<tr>
<td><label class="order-box">Street Address</label></td>
<td><input></td>
</tr>
</table>
</form>
</section>
</div>
I just moved everything into a table, so by default it should line everything up. You may need to tweak the css style further. If you want
something closer to what you had before you can also try splitting things
up into two tables, so that you can have two columns beside each other instead of one column for everything.
Here is an example with two tables:
<div id="order-wrapper">
<section id="order-section">
<h2>Order</h2>
<form id="order-form">
<table style="list-style: none;">
<tr>
<td><label class="order-box">Product Name</label></td>
<td><input></td>
</tr>
<tr>
<td><label class="order-box">Quantity</label></td>
<td><input></td>
</tr>
<tr>
<td><label class="order-box">FIrst Name</label></td>
<td><input></td>
</tr>
<tr>
<td><label class="order-box">Last Name</label></td>
<td><input></td>
</tr>
</table>
<table>
<tr>
<td><label class="order-box">Email</label></td>
<td> <input> </td>
</tr>
<tr>
<td><label class="order-box">Phone Number</label></td>
<td><input></td>
</tr>
<tr>
<td><label class="order-box">Street Address</label></td>
<td><input></td>
</tr>
<tr>
<td><label class="order-box">Something Else..</label></td>
<td><input></td>
</tr>
</table>
</form>
</section>
</div>
My CSS:
#order-form{
width: 100%;
}
#order-form label{
display: inline-block;
width: 25%;
margin-left: 20%;
margin-top: 4%;
}
#order-form input{
width: 60%;
margin-left: 5%;
}
#order-section h2{
font-family:'Homemade Apple', cursive;
font-size:2rem ;
font-weight: 500;
text-align: center;
padding-top: 2%;
margin-top: 0.8%;
}
table {
position: relative;
display: inline-block;
}

Related

Slant table text same as we get in Text-Orientation in MS Excel

I want to create slanted headers for my HTML table as in the screenshot of Excel below. Is there any way to achieve this design using CSS
I tried using Flex
My HTML Code:
.container {
display: flex;
justify-content: space-between;
}
.container > * {
flex: 1;
border: 1px solid black;
padding: 0px 2px;
transform: rotate(-45deg);
}
<div class="container">
<div class="matrix-column">
Column 1
</div>
<div class="matrix-column">
Column 2
</div>
<div class="matrix-column">
Column 3
</div>
<div class="matrix-column">
Column 4
</div>
<div class="matrix-column">
Column 5
</div>
<div class="matrix-column">
Column 6
</div>
</div>
Codepen link: https://codepen.io/a-arora/pen/QWBWvxK
Thanks in advance for your help! :)
I found two online resources that point to the solutions.
Use transform: rotate() and translate()
rotate() to angle the headers and translate() to adjust the positioning. Original article can be found here.
Snippet below:
.table-header-rotated {
border-collapse: collapse;
}
.csstransforms .table-header-rotated td {
width: 30px;
}
.no-csstransforms .table-header-rotated th {
padding: 5px 10px;
}
.table-header-rotated td {
text-align: center;
padding: 10px 5px;
border: 1px solid #ccc;
}
.csstransforms .table-header-rotated th.rotate {
height: 140px;
white-space: nowrap;
}
.csstransforms .table-header-rotated th.rotate > div {
transform: translate(25px, 51px) rotate(315deg);
width: 30px;
}
.csstransforms .table-header-rotated th.rotate > div > span {
border-bottom: 1px solid #ccc;
padding: 5px 10px;
}
.table-header-rotated th.row-header {
padding: 0 10px;
border-bottom: 1px solid #ccc;
}
<script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/modernizr-2.7.1.js"></script>
<table class="table table-header-rotated">
<thead>
<tr>
<!-- First column header is not rotated -->
<th></th>
<!-- Following headers are rotated -->
<th class="rotate"><div><span>Column header 1</span></div></th>
<th class="rotate"><div><span>Column header 2</span></div></th>
<th class="rotate"><div><span>Column header 3</span></div></th>
<th class="rotate"><div><span>Column header 4</span></div></th>
<th class="rotate"><div><span>Column header 5</span></div></th>
<th class="rotate"><div><span>Column header 6</span></div></th>
</tr>
</thead>
<tbody>
<tr>
<th class="row-header">Row header 1</th>
<td><input checked="checked" name="column1[]" type="radio" value="row1-column1"></td>
<td><input checked="checked" name="column2[]" type="radio" value="row1-column2"></td>
<td><input name="column3[]" type="radio" value="row1-column3"></td>
<td><input name="column4[]" type="radio" value="row1-column4"></td>
<td><input name="column5[]" type="radio" value="row1-column5"></td>
<td><input name="column6[]" type="radio" value="row1-column6"></td>
</tr>
<tr>
<th class="row-header">Row header 2</th>
<td><input name="column1[]" type="radio" value="row2-column1"></td>
<td><input name="column2[]" type="radio" value="row2-column2"></td>
<td><input checked="checked" name="column3[]" type="radio" value="row2-column3"></td>
<td><input checked="checked" name="column4[]" type="radio" value="row2-column4"></td>
<td><input name="column5[]" type="radio" value="row2-column5"></td>
<td><input name="column6[]" type="radio" value="row2-column6"></td>
</tr>
<tr>
<th class="row-header">Row header 3</th>
<td><input name="column1[]" type="radio" value="row3-column1"></td>
<td><input name="column2[]" type="radio" value="row3-column2"></td>
<td><input name="column3[]" type="radio" value="row3-column3"></td>
<td><input name="column4[]" type="radio" value="row3-column4"></td>
<td><input checked="checked" name="column5[]" type="radio" value="row3-column5"></td>
<td><input checked="checked" name="column6[]" type="radio" value="row3-column6"></td>
</tr>
</tbody>
</table>
Use transform: rotate() and skew()
Similar to above, but use skew to adjust positioning. See the original Codepen example here.
Snippet below:
.table-header-rotated th.rotate-45 {
height: 160px;
width: 40px;
min-width: 40px;
max-width: 40px;
position: relative;
vertical-align: bottom;
padding: 0;
font-size: 12px;
line-height: 0.8;
}
.table-header-rotated th.rotate-45>div {
position: relative;
top: 0px;
left: -80px;
/* 80 * tan(45) / 2 = 40 where 80 is the height on the cell and 45 is the transform angle*/
height: 100%;
transform: skew(45deg, 0deg);
overflow: hidden;
}
.table-header-rotated th.rotate-45 span {
transform: skew(-45deg, 0deg) rotate(45deg);
position: absolute;
bottom: 120px;
/* 40 cos(45) = 28 with an additional 2px margin*/
left: -25px;
/*Because it looked good, but there is probably a mathematical link here as well*/
display: inline-block;
width: 100%;
width: 85px;
/* 80 / cos(45) - 40 cos (45) = 85 where 80 is the height of the cell, 40 the width of the cell and 45 the transform angle*/
text-align: left;
white-space: nowrap;
/*whether to display in one line or not*/
}
.table-striped-column>thead>tr th:nth-of-type(even) div {
background-color: #eee;
}
.table-striped-column>tbody>tr td:nth-of-type(even) {
background-color: #eee;
}
<body style="padding:50px;">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/2.3.2/css/bootstrap.min.css" />
<div class="row-fluid">
<div class="page-header">
<h2>Assignments for Day 1</h2>
<h4 class="muted">Class #684</h4>
</div>
<table class="table table-header-rotated table-striped table-hover table-striped-column">
<thead>
<tr>
<th class="row-header">Trainee</th>
<!-- Following headers are rotated -->
<th class="rotate-45">
<div><span>Learning Styles Assessment</span></div>
</th>
<th class="rotate-45">
<div><span>Video #2 - Company Value & Goals</span></div>
</th>
<th class="rotate-45">
<div><span>Video #3 - The Technician Job</span></div>
</th>
<th class="rotate-45">
<div><span>Vidoe #5 - Custom Service</span></div>
</th>
<th class="rotate-45">
<div><span>Safety Awareness Questionnaire</span></div>
</th>
<th class="rotate-45">
<div><span>Video #8 - Muscular Injury Prevention</span></div>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>Obama, Barak</td>
<td><span class="label label-success"><i class="icon-ok icon-white"></i></span></td>
<td><span class="label label-success"><i class="icon-ok icon-white"></i></span></td>
<td><span class="label label-success"><i class="icon-ok icon-white"></i></span></td>
<td><span class="label label-success"><i class="icon-ok icon-white"></i></span></td>
<td><span class="label label-success"><i class="icon-ok icon-white"></i></span></td>
<td><span class="label label-success"><i class="icon-ok icon-white"></i></span></td>
</tr>
<tr>
<td>Regan, Ronald</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><span class="label label-success"><i class="icon-ok icon-white"></i></span></td>
<td></td>
</tr>
<tr>
<td>Washington, George</td>
<td></td>
<td></td>
<td></td>
<td><span class="label label-success"><i class="icon-ok icon-white"></i></span></td>
<td></td>
<td><span class="label label-success"><i class="icon-ok icon-white"></i></span></td>
</tr>
</tbody>
</table>
</div>
</body>

Element loses sticky position on hover in MS Edge

The second table header shows another element when is hovered. The problem is that when is hovered it loses the position sticky in MS Edge, and the element stuck when the table is scrolled. It works fine in Chrome and Firefox.
I discovered that it works if the html does not include a DOCTYPE I do not know if is relevant.
td, th {
padding: 5px 15px;
}
th {
position: sticky;
top: 0;
background: black;
color: white;
}
th:hover .disp{
display: inline;
}
.disp {
display: none;
position: relative;
}
.container {
height: 180px;
overflow: scroll;
}
<body>
<div class="container">
<table id="tableId" height="360">
<thead>
<tr>
<th><input type="checkbox" /></th>
<th>Size<div class="disp">hi</div></th>
<th>File</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox" /></td>
<td>103Mb</td>
<td>Text</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>12Mb</td>
<td>Text</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>14Mb</td>
<td>Text</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>16Mb</td>
<td>Text</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>16Mb</td>
<td>Text</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>16Mb</td>
<td>Text</td>
</tr>
</tbody>
</table>
</div>
</body>
I tested the issue with the MS Edge legacy browser 44.18362.449.0 and I can see the issue there.
I check the code and it looks like position: absolute; in .disp class causing this issue.
I Check the documentation but I did not get any information about this behavior.
If you set position as relative or static than the issue can be solved. You can use it as a workaround for this issue.
Code:
td, th {
padding: 5px 15px;
}
th {
position: sticky;
top: 0;
background: black;
color: white;
}
th:hover .disp{
display: block;
align-items: center;
}
.disp {
display: none;
position: relative;
right: 8px;
top: 8px;
}
.container {
height: 180px;
overflow: scroll;
}
<div class="container">
<table id="tableId" height="360">
<thead>
<tr>
<th><input type="checkbox" /></th>
<th>Size<div class="disp">hi</div></th>
<th>File</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox" /></td>
<td>103Mb</td>
<td>Text</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>12Mb</td>
<td>Text</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>14Mb</td>
<td>Text</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>16Mb</td>
<td>Text</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>16Mb</td>
<td>Text</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>16Mb</td>
<td>Text</td>
</tr>
</tbody>
</table>
</div>
Output:
Edit:
If you set display: inline-table;. It will help to fix the issue and both elements will display in the same line.
Output:

Text field wider then number field when setting fieldset padding

fieldset {
width: 510px;
border-width: 1px;
border-color: black;
padding-left: 1em;
padding-right: 1em;
padding-bottom: 2em;
}
*:not(.menu)(fieldset) {
margin: 1;
padding: 1;
}
<form>
<fieldset>
<legend style="font-weight: bold">
Persoonsgegevens
</legend>
<table>
<tr>
<td class="td1"><label for="Voorletters">Voorletters</label></td>
<td class="td2"><input name="Voorletters" type="" /></td>
</tr>
<tr>
<td class="td1"><label for="Achternaam">Achternaam</label></td>
<td class="td2"><input name="Achternaam" type="" /></td>
</tr>
<tr>
<td class="td1"><label for="Huisnummer">Huisnummer</label></td>
<td class="td2"><input name="Huisnummer" type="number" /></td>
<tr>
<tr>
<td class="td1"><label for="Postcode">Postcode</label></td>
<td class="td2"><input name="Postcode" type="text" pattern="^[1-9]{4}[A-Z]{2}" title="Postcode: 1234AA" placeholder="Format: 1234AA" /></td>
</tr>
</table>
</fieldset>
</form>
I'm learning HTML/CSS and working on a form to learn the syntax.
In the form I have a multiple fields like input type="text" input type="number" and type="text" with pattern.
The width of the number and text with pattern fields is smaller then the width of the regular text fields. I've investigated this and solved this by adding the following CSS code:
*:not(.menu){
Margin: 1;
padding: 0;
}
That worked fine but I'm using a fieldset in which I want to set the padding with the following code:
fieldset {
width: 510px;
border-width: 1px;
border-color: black;
padding-left:1em;
padding-right: 1em;
padding-bottom: 2em;
}
This code does not work unless I change the previous code to:
*:not(.menu)(fieldset)
margin: 1;
padding: 1;
}
but then the text field with pattern and number field aren't the same size as the regular text field anymore.
Anybody any ideas how to fix this?
You can set the width of all input fields in the css like this:
fieldset {
width: 510px;
border-width: 1px;
border-color: black;
padding-left:1em;
padding-right: 1em;
padding-bottom: 2em;
}
*:not(.menu)(fieldset){
margin: 1;
padding: 1;
}
input {
width:200px; /*<------Set the width here as you desire*/
}
<form>
<fieldset>
<legend style="font-weight: bold"><h3>Persoonsgegevens</h3></legend>
<table>
<tr>
<td class="td1"><label for="Voorletters">Voorletters</lable></td>
<td class="td2"><input name="Voorletters" type="" /></td>
</tr>
<tr>
<td class="td1"><label for="Achternaam">Achternaam</lable></td>
<td class="td2"><input name="Achternaam" type="" /></td>
</tr>
<tr>
<td class="td1"><label for="Huisnummer">Huisnummer</lable></td>
<td class="td2"><input name="Huisnummer" type="number" /></td>
<tr>
<tr>
<td class="td1"><label for="Postcode">Postcode</lable></td>
<td class="td2"><input name="Postcode" type="text" pattern="^[1-9]{4}[A-Z]{2}" title="Postcode: 1234AA" placeholder="Format: 1234AA" /></td>
</tr>
</table>
</fieldset>
</form>
Here I made a picture, to show you that they are all the same:

Border tr that include th and table section

I am writing my final project at PHP and JS. I need help with the html and CSS styling.
This is my sign form, I want help in 2 things.
I want to do that the whole row (tr) that include th while be with border, now I know to do it only that every th have border.
I want to divide the table to sections and to style every section in other CSS code.
How can I do it?
This my HTML code:
<body>
<form>
<table id="t">
<tr>
<th>Basic info</th>
<th>Contact info</th>
<th>About me</th>
</tr>
<tr>
<td><input placeholder="First name"></td>
<td><input placeholder="Phone"></td>
<td rowspan="3"><textarea rows="8" placeholder="About me"></textarea></td>
</tr>
<tr>
<td><input placeholder="Last name"></td>
<td><input placeholder="Area"></td>
</tr>
<tr>
<td><input placeholder="Degree"></td>
<td><input placeholder="Email"></td>
</tr>
<tr><th colspan="2">Social networks</th></tr>
<tr>
<td><input row placeholder="Facebook link"></td>
<td><input row placeholder="Website link"></td>
</tr>
<tr>
<td><input row placeholder="Twitter link"></td>
<td><input row placeholder="Medium link"></td>
</tr>
<tr>
<td><input row placeholder="Instagram link"></td>
<td><input row placeholder="Google link"></td>
</tr>
<tr><td colspan="2"><button type="submit">שלח</button></td></tr>
</table>
</form>
</body>
This is my CSS:
table{
margin: 16px;
text-align: center;
}
td{
padding: 10px;
justify-content: space-between;
}
#t textarea{
width: 100%;
height: 100%;
}
tr>th{
margin-top: 10px;
border: 1px solid red;
}
For (1), tr's can only have borders when the table is border-collapse:collapse.
For (2), you can put rows in <thead>, <tbody>, <tfoot> sections and style those separately.
Maybe you can have multiple <tbody> sections and use nth-of-type to select them but I don't know.
Differences in the below
addition of thead, tbody, tfoot in the html
style tbody as an example
border-collapse:collapse on the table style
tr style on the first tr
table {
margin: 16px;
text-align: center;
border-collapse: collapse;
}
td {
padding: 10px;
justify-content: space-between;
}
#t textarea {
width: 100%;
height: 100%;
}
tbody {
font-style: italic;
}
<form>
<table id="t">
<thead>
<tr style="border:solid 1px">
<th>Basic info</th>
<th>Contact info</th>
<th>About me</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input placeholder="First name">
</td>
<td>
<input placeholder="Phone">
</td>
<td rowspan="3">
<textarea rows="8" placeholder="About me"></textarea>
</td>
</tr>
<tr>
<td>
<input placeholder="Last name">
</td>
<td>
<input placeholder="Area">
</td>
</tr>
<tr>
<td>
<input placeholder="Degree">
</td>
<td>
<input placeholder="Email">
</td>
</tr>
<tr>
<th colspan="2">Social networks</th>
</tr>
<tr>
<td>
<input row placeholder="Facebook link">
</td>
<td>
<input row placeholder="Website link">
</td>
</tr>
<tr>
<td>
<input row placeholder="Twitter link">
</td>
<td>
<input row placeholder="Medium link">
</td>
</tr>
<tr>
<td>
<input row placeholder="Instagram link">
</td>
<td>
<input row placeholder="Google link">
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="2">
<button type="submit">שלח</button>
</td>
</tr>
</tfoot>
</table>
</form>

Need to center a table within a fieldset within a form

I had a quick HTML/CSS question I hope someone could help me with!
I am trying to learn the specifics of CSS in an online course. I am trying to do a very specific alignment with CSS within a form within a fieldset within a table. I need to have a fieldset split down the middle, and have the label directly on the left, and the input of the form directly on the right. I uploaded 2 pictures: what I have so far and what I am hoping to get, to give a visualization of what I am trying to achieve.
For anyone versed in CSS I am sure this is very easy but it's confusing me. Was just hoping to get some direction!
What I have:
http://imgur.com/gKoWux7
What I want to get:
http://imgur.com/IfeK8D1
Ignore the repetitive code/names in the first image, I am just worried about the alignment of the labels, inputs and buttons.
Here is my HTML:
<!DOCTYPE html>
<html>
<head>
<title>Test 2</title>
<link rel="stylesheet" type="text/css" href="test2.css">
</head>
<body>
<form>
<fieldset>
<legend>Personal Information</legend>
<table>
<tr>
<td><label>First Name:</label></td>
<td><input type="text"></td>
</tr>
<tr>
<td><label>First Name:</label></td>
<td><input type="text"></td>
</tr>
<tr>
<td><label>First Name:</label></td>
<td><input type="text"></td>
</tr>
<tr>
<td><label>First Name:</label></td>
<td><input type="text"></td>
</tr>
<tr>
<td><label>First Name:</label></td>
<td><input type="text"></td>
</tr>
<tr>
<td><label>First Name:</label></td>
<td><input type="text"></td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>Registration Information</legend>
<table>
<tr>
<td><label>First Name:</label></td>
<td><input type="text"></td>
</tr>
<tr>
<td><label>First Name:</label></td>
<td><input type="text"></td>
</tr>
<tr>
<td><label>First Name:</label></td>
<td><input type="text"></td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>Submit Your Registration</legend>
<table>
<tr>
<td><input type="submit"></td>
<td><input type="reset"></td>
</tr>
</table>
</fieldset>
</form>
</body>
</html>
Here is my CSS:
body {
background-color: #A8F89C;
margin: auto;
width: 50%;
}
table {
width: 400px;
table-layout: fixed;
}
fieldset {
width: 410px;
margin: auto;
width: 50%;
}
legend {
font-size: 16px;
font-weight: bold;
}
label {
font-size: 14px;
color: #06127D;
}
td label {
font-weight: bold;
padding-right: 7px;
}
td input {
padding-left: 7px;
}
form input {
width: 140px;
}
label input[type="radio"] {
font-size: 14px;
color: #201E1C;
}
button {
width: 75px;
font-weight: bold;
background-color: rgb(28,67,14);
}
Thank you so much for any help!!!
I just have read your requirement what you want to get.
You can use below mentioned css to get layout like this image
http://imgur.com/IfeK8D1
<style>
fieldset,table{
width:100%
}
td{
width:50%;
}
tbody tr td:first-child{
text-align:right;
padding-right:20px;
}
I hope it will usefull for you as per your need.
Thanks
My idea would add this CSS to (Because label doesn't fill the entire width of the td as label is not a block level element)
td label{
width:100%;
display: inline-block;
text-align:right;
}
or if you prefer you could something like this too, add
td {
text-align: right
}
but it moves all the td elements to right.
Snippet below
Take out the border if needed
body {
background-color: #A8F89C;
margin: auto;
}
table {
table-layout: fixed;
}
fieldset {
width: 410px;
margin: auto;
text-align: center;
}
legend {
font-size: 16px;
font-weight: bold;
}
label {
font-size: 14px;
color: #06127D;
}
td label {
font-weight: bold;
padding-right: 7px;
}
td input {
padding-left: 7px;
}
form input {
width: 140px;
}
label input[type="radio"] {
font-size: 14px;
color: #201E1C;
}
button {
width: 75px;
font-weight: bold;
background-color: rgb(28, 67, 14);
}
table {
border: solid red;
display: inline-table;
}
fieldset {
border: solid blue;
}
td:nth-child(1) {
text-align: right
}
<!DOCTYPE html>
<html>
<head>
<title>Test 2</title>
<link rel="stylesheet" type="text/css" href="test2.css">
</head>
<body>
<form>
<fieldset>
<legend>Personal Information</legend>
<table>
<tr>
<td>
<label>First Name:</label>
</td>
<td>
<input type="text">
</td>
</tr>
<tr>
<td>
<label>First Name:</label>
</td>
<td>
<input type="text">
</td>
</tr>
<tr>
<td>
<label>First Name:</label>
</td>
<td>
<input type="text">
</td>
</tr>
<tr>
<td>
<label>First Name:</label>
</td>
<td>
<input type="text">
</td>
</tr>
<tr>
<td>
<label>First Name:</label>
</td>
<td>
<input type="text">
</td>
</tr>
<tr>
<td>
<label>First Name:</label>
</td>
<td>
<input type="text">
</td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>Registration Information</legend>
<table>
<tr>
<td>
<label>First Name:</label>
</td>
<td>
<input type="text">
</td>
</tr>
<tr>
<td>
<label>First Name:</label>
</td>
<td>
<input type="text">
</td>
</tr>
<tr>
<td>
<label>First Name:</label>
</td>
<td>
<input type="text">
</td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>Submit Your Registration</legend>
<table>
<tr>
<td>
<input type="submit">
</td>
<td>
<input type="reset">
</td>
</tr>
</table>
</fieldset>
</form>
</body>
</html>
First of all using div maybe easier to use ..I have modify a bit of your html where i get rid of the tr and td and use div .Hope this help
<div align = "center">
<label>First Name:</label>
<input type="text">
</div>