Я хотел бы отображать и метку, и ввод в одной строке с использованием CSS для следующей формы. Я пробовал использовать display, float и clear, но не смог получить тот "вид", который кодировал.
Форма должна выглядеть так форма
<header>
<title> Registration form </title>
<link rel = "stylesheet" type = "text/css" href = "style.css">
</header>
<h2>Register here please ! </h2>
<form id = "simpleform">
<fieldset>
<label for = "name">Full Name </label>
<input type = "text" name = "name" id = "name">
<label for = "age">Age in Years </label>
<input type = "number" name = "age" id = "age">
<label for = "email">Email ID</label>
<input type = "email" name = "email" id = "email">
<label for = "email">Email ID</label>
<input type = "email" name = "email" id = "email">
<label for = "gender">Gender</label>
<input type = "radio" name = "gender" value = "male"> Male
<input type = "radio" name = "gender" value = "Female">Female<br>
<label for = "hobbies">Hobbies</label>
<input type = "checkbox" name = "hobbies" value = "Reading"> Reading Books
<input type = "checkbox" name = "hobbies" value = "movies"> Watching Movies
<input type = "checkbox" name = "hobbies" value = "Singing"> Singing
<label for = "country">Country</label>
<select name = "country">
<option value = "us">United States</option>
<option value = "India">India</option>
</select>
<br>
<lable for = "comments">Comments</lable>
<textarea name = "comments" id = "comments" rows=5 cols = "50"></textarea>
<input type = "submit">
<input type = "reset" value = "Start Again">
</fieldset>
</form>





Есть много способов получить макет из 2 столбцов, но использование table, вероятно, является наиболее простым и понятным, например:
<form id = "simpleform">
<fieldset>
<table>
<tr>
<td><label for = "name">Full Name</label></td>
<td><input type = "text" name = "name" id = "name"></td>
</tr>
<tr>
<td><label for = "age">Age in Years</label></td>
<td><input type = "number" name = "age" id = "age"></td>
</tr>
<tr>
<td><label for = "email">Email ID</label></td>
<td><input type = "email" name = "email" id = "email"></td>
</tr>
<tr>
<td><label for = "gender">Gender</label></td>
<td>
<input type = "radio" name = "gender" value = "male"> Male
<input type = "radio" name = "gender" value = "Female">Female
</td>
</tr>
<tr>
<td><label for = "hobbies">Hobbies</label></td>
<td>
<input type = "checkbox" name = "hobbies" value = "Reading"> Reading Books
<input type = "checkbox" name = "hobbies" value = "movies"> Watching Movies
<input type = "checkbox" name = "hobbies" value = "Singing"> Singing
</td>
</tr>
<tr>
<td><label for = "country">Country</label></td>
<td>
<select name = "country">
<option value = "us">United States</option>
<option value = "India">India</option>
</select>
</td>
</tr>
<tr>
<td><lable for = "comments">Comments</lable></td>
<td>
<textarea name = "comments" id = "comments" rows=5 cols = "50"></textarea>
</td>
</tr>
<tr>
<td></td>
<td>
<input type = "submit">
<input type = "reset" value = "Start Again">
</td>
</tr>
</table>
</fieldset>
</form>Понятно, но вся идея состоит в том, чтобы также использовать стили css.
Я переработал свои html и css и получил желаемый результат
*{
margin: 0;
padding: 0;
}
body{
font-family:verdana sans-serif;
background-color: #99ffcc;
}
h2{
margin-top: 100px;
text-align: center;
color: blue;
}
#simpleform{
width: 500px;
margin: auto;
height: 400px;
border: 1px solid red;
background-color: #ccc;
}
label{
text-align: right;
clear: left;
float: left;
padding-right:13px;
margin-top: 12px;
width: 150px;
}
input,textarea {
margin-top: 12px;
width: auto;
}
input[type = "email"]{
margin-top:16px;}
input[type = "radio"]{
margin-top: 16px;
}
input[type = "checkbox"]{
margin-top: 16px;
}
input[type = "number"]{
margin-top:16px;
}
select{
margin-top: 13px;
}
#buttons{
margin-left:160px;
}
input[type = "submit"]{
margin-right:80px;
background-color: white;
padding: 10px;
border-radius:10px;
border: 1px solid black;
}
input[type = "reset"]{
margin-right:80px;
background-color: white;
padding: 10px;
border-radius:10px;
border: 1px solid black;}
input[type = "submit"]:hover
{
background-color: aquamarine;
}
input[type = "reset"]:hover
{
background-color: aquamarine;
}
input[type = "text"],input[type = "number"],input[type = "email"]{
width:200px;
border: 1px solid black;
}<html>
<header><title> Registration form </title>
<link rel = "stylesheet" type = "text/css" href = "style.css">
</header>
<body>
<h2>Register here please ! </h2>
<form id = "simpleform">
<div>
<label for = "name">Full Name </label>
<input type = "text" name = "name" id = "name">
</div>
<div>
<label for = "age">Age in Years </label>
<input type = "number" name = "age" id = "age">
</div>
<div>
<label for = "email">Email ID</label>
<input type = "email" name = "email" id = "email">
</div>
<div>
<label for = "gender">Gender</label>
<input type = "radio" name = "gender" value = "male"> Male
<input type = "radio" name = "gender" value = "Female">Female<br>
</div>
<div>
<label for = "hobbies">Hobbies</label>
<input type = "checkbox" name = "hobbies" value = "Reading"> Reading Books
<input type = "checkbox" name = "hobbies" value = "movies"> Watching Movies
<input type = "checkbox" name = "hobbies" value = "Singing"> Singing
</div>
<div>
<label for = "country">Country</label>
<select name = "country">
<option value = "us">United States</option>
<option value = "India">India</option>
</select><br>
</div>
<div>
<label for = "comments" id = "lable-comment">Comments</label>
<textarea name = "comments" id = "comments" rows=5 cols = "50"></textarea>
</div>
<div id = "buttons">
<input type = "submit">
<input type = "reset" value = "Start Again"></div>
</form>
</body>
</html>
Пожалуйста, опубликуйте также свой CSS и подумайте о том, чтобы поместить свое изображение в строку, а не в качестве ссылки - это облегчит другим чтение вашего вопроса. Спасибо!