Arrange two checkboxes in same table cell vertically - html

I'm wondering if possible to arrange two checkbox input fields vertically in same td cell? Below is example, there both of input fields are next to each other.
<table>
<tr>
<td>
<input type="number" />
<input type="checkbox" name="ck1" id="ck1">A
<input type="checkbox" name="ck2" id="ck2">B
</td>
</tr>
</table>

How about using a simple <br> with using text-align:right on the <td>?
<table>
<tr>
<td style='text-align:right'>
<input type="number">
<input type="checkbox" name="ck1" id="ck1">A<br>
<input type="checkbox" name="ck2" id="ck2">B
</td>
</tr>
</table>

Related

Possible to create a matrix of INPUTs using CSS and a TABLE?

Let's say we want to make a tic-tac-toe game. Is in possible with three TRs, each with only one TD containing three INPUTs? Or does each TR require three TDs, each TD containing one INPUT?
Really depends on what you want to do.
input{
width:50px;
height:50px;
text-align:center;}
<table>
<tr>
<td>
<input type='text' value="X">
<input type='text' value="O">
<input type='text' value="X">
</td>
</tr>
</table>
<table>
<tr>
<td>
<input type='text'>
</td>
<td>
<input type='text'>
</td>
<td>
<input type='text'>
</td>
</tr>
</table>

display text and image input inline in table

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;
}

How to put line break between th and td?

I have table and I would like to put my td's under th tags. Here is my HTML code:
<table>
<tr>
<th>Your Email</th>
<td>
<input type="text" name="userEmail" value="" id="userEmail" required="">
</td>
</tr>
<tr>
<th>Job Category</th>
//I need break line here
<td>
<label><input type="radio" name="rd1" value="Programmer" id="rd1">Programmer</label><br>
<label><input type="radio" name="rd2" value="Web Developer" id="rd2">Web Developer</label><br>
</td>
<tr>
</table>
My output gives me text in <th> tags and then text in <td> tags next to it. I would like to have td content below th. I tried to use <br> tags but looks like that does not work outside of td tags. If anyone know the best and way to fix this please let me know.
You are creating a table and nothing can be put outside the table cells. If you want to have the forms element under the headers, just create one row with headers and one row with forms elements:
<table>
<tr>
<th>Your Email</th>
<th>Job Category</th>
</tr>
<tr>
<td>
<input type="text" name="userEmail" value="" id="userEmail" required="">
</td>
<td>
<label><input type="radio" name="rd1" value="Programmer" id="rd1">Programmer</label><br>
<label><input type="radio" name="rd2" value="Web Developer" id="rd2">Web Developer</label><br>
</td>
<tr>
</table>
Put your table header in its own row:
<table>
<tr>
<th scope="row">Your Email</th>
<td>
<input type="text" name="userEmail" value="" id="userEmail" required="">
</td>
</tr>
<tr>
<th colspan="2">Job Category</th>
</tr>
<tr>
//I need break line here
<td colspan="2">
<label><input type="radio" name="rd1" value="Programmer" id="rd1">Programmer</label><br>
<label><input type="radio" name="rd2" value="Web Developer" id="rd2">Web Developer</label><br>
</td>
</tr>
</table>
Place them in different rows using
<table>
<tr>
<th scope="row">Your Email</th>
<td>
<input type="text" name="userEmail" value="" id="userEmail" required="">
</td>
</tr>
<tr>
<th>Job Category</th>
</tr>//End row
//I need break line here
<tr> //start new row
<td>
<label><input type="radio" name="rd1" value="Programmer" id="rd1">Programmer</label><br>
<label><input type="radio" name="rd2" value="Web Developer" id="rd2">Web Developer</label><br>
</td>
<tr>
</table>

How to display second checkbox name aligned

<html>
<table width="45%"><tr><td>
<input type="checkbox" name="mahesh" value="mahesh">Mahesh</td>
<td>
<input type="checkbox" name="mahesh" value="mahesh">Mahesh kunenaddsfsdfasdfasdfa</td></tr>
<tr><td>
<input type="checkbox" name="mahesh" value="mahesh">Mahesh</td>
<td>
<input type="checkbox" name="mahesh" value="mahesh">Mahesh kunenaddsfsdfasdfasdfa</td></tr>
</table></html>
I want second check box name is to large, it should align properly below the name .
It should start from the name not form checkbox
you can use additional element - label, like this:
HTML:
<table width="45%">
<tr>
<td>
<input type="checkbox" name="mahesh1" value="mahesh"/>Mahesh
</td>
<td>
<input type="checkbox" id="maesh1" name="mahesh1" value="mahesh"/>
<label for="maesh1"> Mahesh kunenaddsfsdfasdfasdfa</label>
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="mahesh2" value="mahesh"/>Mahesh
</td>
<td>
<input type="checkbox" id="maesh2" name="mahesh2" value="mahesh"/>
<label for="maesh2"> Mahesh kunenaddsfsdfasdfasdfa</label>
</td>
</tr>
css:
label {
display: block;
white-space: nowrap;
}
fiddle:
http://jsfiddle.net/ywg632c3/2/

Why are my table rows not aligned?

I have an html table
For some reason, in the second row, the two cells are not horizontally aligned. What is the cause of this?
<input type="checkbox" id="3" onClick="change(this)" checked="">
<label for="2"><font color="800080"> Ice Cover (Days)</font></label></p>
In this cell you have label for input with id="2" but in cell is input id="3" change with <label for="3">
this should fix it. you had an extra td tag and an extra br tag in there, and I also gave the title of the table its own row.
<div id="menu" STYLE="position:absolute; left:25px">
<!--toggles visibility of graph lines-->
<table>
<tr>
<td>
<p><b>Display: </b>
</td>
</tr>
<tr>
<td><input type="checkbox" id="0"
onClick="change(this)" checked="">
<label for="0"> <font color="556b2f">Freeze up (Julian Days)</font></label>
</td>
<td><input type="checkbox" id="1"
onClick="change(this)" checked="">
<label for="1"> <font color="000080">Break up (Julian Days)</font></label>
</td>
</tr>
<tr>
<td><input type="checkbox" id="2"
onClick="change(this)" checked="">
<label for="2"><font color="2e8b57"> Max Ice Thickness (cm)</font></label>
</td>
<td><input type="checkbox" id="3"
onClick="change(this)" checked="">
<label for="2"><font color="800080"> Ice Cover (Days)</font></label></p>
</td>
</tr>
</table>
</div>