display text and image input inline in table - html

Hello I want to display a text and image input inside a table like this:
I've tried this code:
<tbody>
<tr>
<td class="inputs">
<input type="text" id="input1" size="3"/>
</td>
<td class="inputs">
<input type="text" id="input2" />
</td>
<td class="inputs">
<input type="text" id="input3" size="10"/>
</td>
<td class="inputs">
<input type="text" id="input4" size="8"/>
<input type="image" src="button.png" />
</td>
<td class="inputs">
<input type="text" id="input5" size="10"/>
</td>
<td class="inputs">
<input type="checkbox" id="input6" />
</td>
</tr>
But the result is this:
Any ideas how to fix this? Please help!

Vertical alignment is the problem here. Simply specify vertical-align: top on your input elements within your table cells and they will all align to the same position (the top, in this case):
td input {
vertical-align: top;
}

Related

Form does not align properly

So I have written the following code and I cannot make same response as I was asked to. the text does not align properly in form. The text isn't like aligned right and feilds on left. I Please suggest a fix as simple as you can.
<form align="center">
<p>Name:
<input type="text">
</p>
<p>Address
<input type="text">
</p>
<p>Email ID:
<input type="text">
</p>
<p>How many Peices of fruit<br>
do you eat per day?
<input type="radio" name="rdbGender" id="rdbGender"> 0
<input type="radio" name="rdbGender" id="rdbGender">1
<input type="radio" name="rdbGender" id="rdbGender">2<br>
<input type="radio" name="rdbGender" id="rdbGender">More than 2<br>
</p>
<label>Degree:</label>
<select multiple>
<option selected>apple</option>
<option>banana</option>
<option>plum</option>
<option>pomegranate</option>
</select>
<p>Would you like a <br /> brochure?
<input type="checkbox" align="right">
</p>
<input type="submit">
</form>
How it was supposed to look like
How it looks like
I had a hard time understand how you had been writing this code:
<form align="center">
and
<input type="checkbox" align="right"/>
As align is not a valid attribute of an input or form tag.
But what it looks like is that it used, and has long since been removed.
https://www.w3.org/TR/html401/present/graphics.html#adef-align
Note that on my browser (Firefox 81.0) your code doesn't center align like it does in your picture:
So that suggests to me that you are using an old browser.
I recommend using the MDN documentation to see what is elements are supported.
However, if you are supporting outdated then that's a whole discipline in itself.
This page lists all available HTML attributes:
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
To give you a useful answer though - judging on the 'supposed to look like' image, it looks like you want to be using a table.
<form>
<table>
<tr>
<td align="right">Name:</td>
<td><input type="text"></td>
</tr>
<tr>
<td align="right">Address</td>
<td><input type="text"></td>
</tr>
<tr>
<td align="right"> Email ID:</td>
<td> <input type="text"></td>
</tr>
<tr>
<td align="right"> How many Peices of fruit do you eat per day?</td>
<td>
<input type="radio" name="rdbGender" id="rdbGender"> 0
<input type="radio" name="rdbGender" id="rdbGender">1
<input type="radio" name="rdbGender" id="rdbGender">2<br>
<input type="radio" name="rdbGender" id="rdbGender">More than 2 </td>
</tr>
<tr>
<td align="right">
Degree:
</td>
<td>
<select multiple>
<option selected>apple</option>
<option>banana</option>
<option>plum</option>
<option>pomegranate</option>
</select>
</td>
</tr>
<tr align="right">
<td> Would you like a brochure</td>
<td align="left"> <input type="checkbox"></td>
</tr>
<tr>
<td></td>
<td> <input type="submit"></td>
</table>
</form>
Note here, we do use the align attribute. As you can see, according to the MDN documentation, align is supported on a td element, but is deprecated, meaning that it's not advisable to use it.
Do you want like this? Only html:
<form>
<table align="center">
<tr>
<td align="right">Name </td>
<td><input type="text"></td>
</tr>
<tr>
<td align="right"><br>Address </td>
<td><br><input type="text"></td>
</tr>
<tr>
<td align="right"><br>Email ID </td>
<td><br><input type="text"></td>
</tr>
<tr>
<td>
<label for="rdbGender">
<br>
How many Peices of fruit <br> do you eat per day?<br><br><br><br>
</label>
</td>
<td>
<input type="radio" name="rdbGender" id="rdbGender">0<br>
<input type="radio" name="rdbGender" id="rdbGender">1<br>
<input type="radio" name="rdbGender" id="rdbGender">2<br>
<input type="radio" name="rdbGender" id="rdbGender">More than 2
</td>
</tr>
<tr>
<td align="right">
<br>
<label for="degree">
My favourite fruit <br><br><br><br><br>
</label>
</td>
<td>
<select id="degree" multiple>
<option selected>apple</option>
<option>banana</option>
<option>plum</option>
<option>pomegranate</option>
</select>
</td>
</tr>
<tr align="right">
<td> Would you like a <br>
brochure
</td>
<td align="left"> <input type="checkbox"></td>
</tr>
<tr>
<td></td>
<td>
<br>
<input type="submit">
</td>
</table>
</form>
I suggest you to use CSS Grid to accomplish this job:
form {
display: grid;
grid-template-columns: 150px 200px;
text-align: center;
}
.first-column {
text-align: right;
}
input, select {
margin-left: 5px;
margin-bottom: 5px;
}
.check-area label {
display: block;
text-align: left;
}
.submit-button {
grid-column-start: 2;
text-align: left;
}
<form>
<label class="first-column">Name:</label><input type="text">
<label class="first-column">Address</label><input type="text">
<label class="first-column">Email ID:</label><input type="text">
<div class="first-column">
How many Peices of fruit<br>do you eat per day?
</div>
<div class="check-area">
<label>
<input type="radio" name="rdbGender" id="rdbGender">0
</label>
<label>
<input type="radio" name="rdbGender" id="rdbGender">1
</label>
<label>
<input type="radio" name="rdbGender" id="rdbGender">2
</label>
<label>
<input type="radio" name="rdbGender" id="rdbGender">More than 2
</label>
</div>
<label class="first-column">Degree:</label>
<select multiple>
<option selected>apple</option>
<option>banana</option>
<option>plum</option>
<option>pomegranate</option>
</select>
<label class="first-column">Would you like a<br>brochure?</label>
<input type="checkbox" align="right">
<div class="submit-button"><input type="submit"></div>
</form>

How to make the input text wider

I trying to make the text bar wider but I cant get it to work. I have tried with width but it didn't work for me. I also couldn't find anything on the internet.
This is my HTML:
HTML:
<form action="" method="post">
<legend>Neem contact op</legend>
<table>
<tr>
<td>
<label for="Naam">Naam: </label>
</td>
<td>
<input type="text" id="Naam" name="Naam" placeholder="Naam" required="required" />
</td>
</tr>
<tr>
<td>
<label for="Email">Email :</label>
</td>
<td>
<input type="email" id="Email"name="Email" placeholder="Email" required="required" />
</td>
</tr>
<tr>
<td>
<label for="Seizoen">Seizoen: </label>
</td>
<td>
<select name="Seizoen" id="Seizoen" required>
<option value="">Kies hier je seizoen</option>
<option value="Lente">Lente</option>
<option value="Zomer">Zomer</option>
<option value="Herfst">Herfst</option>
<option value="Winter">Winter</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td>
<label for="Benodigheden">Benodigheden:</label>
</td>
<td>
<input type="text" id="Benodigheden"name="Benodigheden" placeholder="Benodigheden" required="required" />
</td>
</tr>
<tr>
<td>
<label for="Opmerking">Opmerking:</label>
</td>
<td>
<textarea name="Opmerking" id="Opmerking" cols="40" rows="5" placeholder="Opmerking" required="required" /></textarea>
</td>
</tr>
<tr>
<td>
</td>
<td>
<div class="submit"><input type="submit" value="Verzenden" name="Verzenden" /></div>
</td>
</tr>
</table>
Here is a link to JSFiddle.
While the above code is very good, minimal and clean, which is best. But IF you need different widths for each of your text inputs then inline CSS is needed.
Example code:
<input style="width: 300px;" type="text">
<input style="width: 340px;" type="text">
If you only wish to make input-type="text" have a certain width, add this style in your css file fx:
input[type=text] {
width: 300px;
}
add some css to the head section of your html
<style>
input{width: 300px}
</style>
Make your table wider.
Add desired width to your td's
Ajust your inputs widht.

TD width not changing with input fields

My goal is to make each TD have a width of 100px which should also make the input fields be 100px. However, when I added width="100" to a TD, nothing happens. Here's the HTML code:
<table>
<tr>
<td>2.</td>
<td width="100">
<input type="text" name="year2" id="year2" value="" />
</td>
<td width="100">
<input type="text" name="make2" id="make2" value="" />
</td>
<td width="100">
<input type="text" name="vin2" id="vin2" value="" />
</td>
<td width="100">
<input type="text" name="radius2" id="radius2" value="" />
</td>
<td width="100">
<input type="text" name="gvm2" id="gvm2" value="" />
</td>
<td width="100">
<input type="text" name="comp2" id="comp2" value="" />
</td>
<td width="100">
<input type="text" name="coll2" id="coll21" value="" />
</td>
<td width="100">
<input type="text" name="amt2" id="amt2" value="" />
</td>
</tr>
</table>
Here's a link to the JSFiddle
I would appreciate any help.
The style should be added on your <input> not on your <td>. Also you should manage this via CSS instead of using inline styles.
In your CSS add
.my-width {
width: 100px;
}
Then add that class to each of your inputs:
<input class="my-width" type="text" name="year2" id="year2" value="" />
JS Fiddle Demo
Add style="width: 100px" to each input or add to your css file
input[type="text"]{
width: 100px;
}
Here is fiddle for the second option

How do you align the label

How do I align the "remember me" box so that it comes to left side so that the checkbox should start with username and password text boxes start.
Current it is -
<tr>
<td colspan="2" class="buttons">
<label>
<input id="rememberme" name="rememberme" value="remember" type="checkbox" /> Remember me</label>
<input type="submit" name="login" value="Login" />
</td>
</tr>
Add a label around your "Remember Me" text and assign a class to it;
Then give that class the following style:
.aux {
float: left;
}
<tr>
<td colspan="2" class="buttons">
<label>
<input id="rememberme" name="rememberme" value="remember" type="checkbox" />
<label class="aux"> Remember me</label>
</label>
<input type="submit" name="login" value="Login" />
</td>
</tr>
Is this you're looking for?
you will need to remove margin for checkbox which is given by default
check for the first
Js Fiddle
.valign{
vertical-align: bottom;
}
input{
margin:0;
}
try to insert your form in a two columns table:
<table>
<tr>
<td>User Name:</td>
<td><Input type="text"/></td>
</tr>
<tr>
<td>Password:</td>
<td><Input type="password"/></td>
</tr>
<tr>
<td></td>
<td class="buttons">
<label><input id="rememberme" name="rememberme" value="remember" type="checkbox" /> Remember me</label>
<input type="submit" name="login" value="Login"/>
</td>
</tr>
fiddle: http://jsfiddle.net/2wj86k32/
<tr><td class="buttons"><label>Username</label></td>
<td><input id="rememberme" name="rememberme" type="text" /></td></tr>
<tr><td class="buttons"><label>Username</label></td>
<td><input id="rememberme" name="rememberme" type="text" /></td></tr>
<tr><td class="buttons"></td>
<td><input id="rememberme" name="rememberme" type="checkbox" /><label>remember me</label><input type="submit" value="Login" /></td></tr>
Is it your need ?

Line up radio buttons

I have the following HTML:
<tr>
<td class=tabTwo vAlign=top>
<table border=0 cellPadding=0 cellSpacing=0 width=100%>
<tr>
<td vAlign=top width=5%>4.</td>
<td>Test 1?</td>
</tr>
<tr>
<td width=5%></td>
<td colSpan=2>a) <input type="radio" name="S1Q4" value="a" id="s1q4a" /> <label for="s1q4a">A</label></td>
</tr>
<tr>
<td width=5%></td>
<td colSpan=2>b) <input type="radio" name="S1Q4" value="b" id="s1q4b" /> <label for="s1q4b">B</label></td>
</tr>
<tr>
<td width=5%></td>
<td colSpan=2>c) <input type="radio" name="S1Q4" value="c" id="s1q4c" /> <label for="s1q4c">C</label></td>
</tr>
<tr>
<td width=5%></td>
<td colSpan=2>d) <input type="radio" name="S1Q4" value="d" id="s1q4d" /> <label for="s1q4d">D</label></td>
</tr>
</table>
</td>
</tr>
Produces:
How do I made the radio buttons align in a straight line? B & C seem crooked.
If you are going to use a table. Put the inputs in their own cell. The letter width of a),b) etc. is what is throwing of the alignment.
I would not use a table though. Your choice.
Your question seemed a little vague but to best my knowledge, the presence of bullets a) b) c) in the same cell is causing the problem. Here's my fiddle: http://jsfiddle.net/bTNvA/
I have tried to resolve this by moving bullets to other cell:
<tr>
<td width=5%> a) </td>
<td colSpan=2> <input type="radio" name="S1Q4" value="a" id="s1q4a" /> <label for="s1q4a">A</label></td>
</tr>
HTML
<div class="form-wrapper">
<div class="radio-choice">
<span>a) </span>
<input id="option1" type="radio" name="opt1"/>
<label for="option1">Option 1</label>
</div>
<div class="radio-choice">
<span>b) </span>
<input id="option2" type="radio" name="opt2"/>
<label for="option2">Option 2</label>
</div>
<div class="radio-choice">
<span>c) </span>
<input id="option3" type="radio" name="opt3"/>
<label for="option3">Option 3</label>
</div>
</div>
CSS
.radio-choice * {
vertical-align: middle;
}
.form-wrapper div{
float: left;
clear: both;
}
.form-wrapper span {
display: inline-block;
width: 10px;
}
http://jsfiddle.net/NewwV/1/