I would like to shift the form up to the image. However, I have tried but I still could not shift the whole form up.
Below is the html and css codes:
/* Container holding the image and the text */
.container {
position: relative;
text-align: left;
color: black;
}
/* Encounter issues here, please take a look at the second image*/
.formcontainer {
position: absolute;
top: 8px;
left: 16px;
}
<div class="container">
<img src="https://picsum.photos/1000/600.jpg" class="body">
<h2> Registration </h2>
<div class="formcontainer">
<form action>
<label for="name">Name :</label> <br>
<input type="text" name="name" value="Enter your name"></input>
<br>
<label for="age">Age :</label> <br>
<input type="number" name="age" min="1"></input>
<br>
<label for="gender">Gender :</label> <br>
<input type="radio" name="gender" value="male"> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<br>
<label for="membertype">Types of membership :</label> <br>
<select name="type">
<option value="OneYr">1 Year</option>
<option value="FiveYr" selected>5 Years</option>
<option value="LifeTime">Life Time</option>
</select>
<br>
<br/>
<label for="interests">Interests :</label>
<br>
<input type="checkbox" name="interest" value="Bike"> Travel<br>
<input type="checkbox" name="interest" value="Food"> Food<br>
<input type="checkbox" name="interest" value="Shopping"> Shopping<br>
<input type="checkbox" name="interest" value="Cars"> Cars<br>
</br>
<input type ="button" name="submit" value="Submit">
</form>
</div>
</div>
After I have tried using the above .formcontainer css codes:
Just add your image in .container style not using img tag.
.container{
background-image: url("../img/gym.jpg");
}
See the Snippet below:
.container{
background-image: url("https://i.stack.imgur.com/3dbsg.png");
}
<div class="container">
<img src="../img/gym.jpg" class="body">
<h2> Registration </h2>
<div class="formcontainer">
<form action>
<label for="name">Name :</label> <br>
<input type="text" name="name" value="Enter your name"></input>
<br>
<label for="age">Age :</label> <br>
<input type="number" name="age" min="1"></input>
<br>
<label for="gender">Gender :</label> <br>
<input type="radio" name="gender" value="male"> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<br>
<label for="membertype">Types of membership :</label> <br>
<select name="type">
<option value="OneYr">1 Year</option>
<option value="FiveYr" selected>5 Years</option>
<option value="LifeTime">Life Time</option>
</select>
<br>
<br/>
<label for="interests">Interests :</label>
<br>
<input type="checkbox" name="interest" value="Bike"> Travel<br>
<input type="checkbox" name="interest" value="Food"> Food<br>
<input type="checkbox" name="interest" value="Shopping"> Shopping<br>
<input type="checkbox" name="interest" value="Cars"> Cars<br>
</br>
<input type ="button" name="submit" value="Submit">
</form>
</div>
</div>
Not a UI expert, but adding the image as background to the parent-div should do.
.container {
background-image: url("https://i.ibb.co/xJCmfmT/test3.jpg");
position: relative;
text-align: left;
color: black;
}
You can do this in couple of ways as far as I know.
set the image as parent div (container here) background using
.container {
background-image: url(IMAGE_URL);
}
set position of formcontainer as absolute
.formcontainer {
position: absolute;
}
Related
I cant figure out why the Favorite Food dropdown menu won't line up with the text input boxes above it.
I have tried moving around alot of the opening and closing tags to see if that would help but got nowhere. Tried adding some break tags, nothing. I also tried using the grid and display property with different values. I also tried using css grids and that didn't work at all.
#survey-form{
background-color:gray;
border-radius:10px;
z-index:2;
position:relative;
/*top:-700px;*/
padding-top:30px;
padding-bottom:100px;
width:60%;
margin:0px auto;
opacity:70%;
text-align:center;
}
.labels{
display: inline-block;
text-align: right;
vertical-align:top;
width: 40%;
padding: 5px;
font-family:Helvetica;
color:white;
/*background:white;*/
float:left;
}
.input {
width: 280px;
height: 29px;
border-radius: 2px;
border: 5px;
border-color: grey;
}
.right{
display:inline-grid;
text-align: left;
width: 18%;
margin:0px auto;
/* background:yellow;*/
}
<div class="survey">
<form id="survey-form">
<label for="name" id="name-label"
class="labels"> Name: </label>
<div class="right">
<input id="name" class="input" type="text" placeholder="Name" required>
</div><br>
<label for="email" id="email-label" class="labels"> Email: </label>
<div class="right">
<input id="email" class="input" type="email" placeholder="Email" required>
</div><br>
<label for="number" id="number-label" class="labels"> Age: </label>
<div class="right">
<input id="number" class="input" type="number" placeholder="Enter Age" min="1" max="120" required>
</div><br>
<!--problem starts here-->
<label for="food" class="labels"> Favorite Food:</label>
<div class:"right">
<select id="dropdown" name="food" class="input"><br>
<option value="select"> Select an option </option>
<option value="pizza"> Pizza </option>
<option value="biryani"> Biryani </option>
<option value="fried-rice"> Fried Rice </option>
</select>
</div><br>
<!--problem ends here-->
<label class="labels" for="radio">Chicken or Steak:</label>
<ul class="right" style="list-style: none;">
<li class="radio">
<input name="radio-buttons" value="1" type="radio"><label>Chicken</label>
</input></li>
<li class="radio">
<input name="radio-buttons" type="radio" value="2" ><label>Steak</label></input></li>
</ul><br></br>
<label for="sports" class="labels"> What sport(s) do you play</label>
<ul id="sports" style="list-style: none" class="right">
<li class="checkbox"><label><input type="checkbox" id="hockey" value="1"> Hockey</label></input></li>
<li class="checkbox"><label><input type="checkbox" id="badminton"value="2"> Badminton </label></input></li>
<li class="checkbox"><label><input type="checkbox" id="badminton"value="3"> Basketball(#ballislife) </label></input></li>
<li class="checkbox"><label><input type="checkbox" id="soccer"value="4"> Soccer </label></input></li>
</ul><br>
<label for="comment" class="labels"> Any Comments or Suggestions? </label>
<textarea id="comment" name="comment" rows="4" cols="50" placeholder="Comments here..."></textarea>
<br></br>
<button id="submit" type="submit">Submit</button>
</form>
</div>
In the div which contains the dropdown, you have a syntax error <div class:"right">. It should be <div class="right">.
Maybe this is causing the problem.
I'm trying to use flexbox in the following snippet.
However, the header and the div below it do not seem to get the CSS styling. If I remove the flexbox setting in the container div the header shows on top of the form div. But when I add display flex it puts the header and form div side by side.
Why does this happen? I am trying to show the header on top and form div below it and then horizontally center with justify-content: center. Thanks.
.container {
display: flex;
justify-content: center;
align-items: center;
}
header {
border: 1px solid black;
}
#form {
border: 1px solid black;
}
<div class="container">
<header>
<h1 id="title">Survey Form</h1>
<p id="description">Thank you for helping us improve by taking this survey.</p>
</header>
<div id="form">
<form id="survey-form">
<div class="form-group">
<label id="name-label" for="name">Name</label>
<input type="text" id="name" name="name" placeholder="Enter your name" required>
</div>
<div class="form-group">
<label id="email-label" for="email">Email</label>
<input type="email" id="email" name="email" placeholder="Enter your email" pattern=".+#.+\..+" required>
<div>
<div class="form-group">
<label id="number-label" for="number">Age (optional)</label>
<input type="number" id="number" name="age" placeholder="Enter your email" min="1" max="200" required>
<div class="form-group">
<p>What's your coding experience?</p>
<label>
<input type="radio" name="user-experience" value="noob" class="input-radio" />
Noob
</label>
<label>
<input type="radio" name="user-experience" value="dangerous" class="input-radio" checked/>
Dangerous
</label>
<label>
<input type="radio" name="user-experience" value="veteran" class="input-radio" />
Veteran
</label>
</div>
<div class="form-group">
<p>What programing language do you use the most at work?</p>
<select id="dropdown" class="form-group" name="language" required>
<option disabled selected value>Select a language</option>
<option value="java">Java</option>
<option value="javascript">JavaScript</option>
<option value="python">Python</option>
<option value="c++">C++</option>
<option value="c">C</option>
<option value="c#">C#</option>
<option value="php">PHP</option>
<option value="ruby">Ruby</option>
</select>
</div>
<div class="form-group">
<p>Do you like to work on the Front-end or Back-end? <span class="clue">(Check all that apply)</span</p>
<label>
<input name="prefer" value="front-end-projects" type="checkbox" class="input-checkbox" />Front-end
</label>
<label>
<input name="prefer" value="back-end-projects" type="checkbox" class="input-checkbox" />Back-end
</label>
</div>
<div class="form-group">
<p>Please provide any comments if we missed anything?</p>
<textArea id="comments" name="comment" placeholder="Place your comments here..."></textArea>
<div>
<div class="form-group">
<button type="submit" id="submit" class="submit-button">Submit</button>
<div>
</form>
</div>
</div>
You wanna use the flex-direction property. It takes four values:
row
column
row-reverse
column-reverse
You wanna edit container class to this:
.container {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
For more information on Ordering Flex Items see the docs
Edit:
You can use the flex-flow property, which is a css-shorthand property for:
flex-direction
flex-wrap
Default behaviour for display: flex is to align items in a row. You can change this by adding flex-flow: column to align the items in a column.
.container {
display: flex;
justify-content: center;
align-items: center;
flex-flow: column; /* added flex-flow: column here*/
}
header {
border: 1px solid black;
}
#form {
border: 1px solid black;
}
<div class="container">
<header>
<h1 id="title">Survey Form</h1>
<p id="description">Thank you for helping us improve by taking this survey.</p>
</header>
<div id="form">
<form id="survey-form">
<div class="form-group">
<label id="name-label" for="name">Name</label>
<input type="text" id="name" name="name" placeholder="Enter your name" required>
</div>
<div class="form-group">
<label id="email-label" for="email">Email</label>
<input type="email" id="email" name="email" placeholder="Enter your email" pattern=".+#.+\..+" required>
<div>
<div class="form-group">
<label id="number-label" for="number">Age (optional)</label>
<input type="number" id="number" name="age" placeholder="Enter your email" min="1" max="200" required>
<div class="form-group">
<p>What's your coding experience?</p>
<label>
<input type="radio" name="user-experience" value="noob" class="input-radio" />
Noob
</label>
<label>
<input type="radio" name="user-experience" value="dangerous" class="input-radio" checked/>
Dangerous
</label>
<label>
<input type="radio" name="user-experience" value="veteran" class="input-radio" />
Veteran
</label>
</div>
<div class="form-group">
<p>What programing language do you use the most at work?</p>
<select id="dropdown" class="form-group" name="language" required>
<option disabled selected value>Select a language</option>
<option value="java">Java</option>
<option value="javascript">JavaScript</option>
<option value="python">Python</option>
<option value="c++">C++</option>
<option value="c">C</option>
<option value="c#">C#</option>
<option value="php">PHP</option>
<option value="ruby">Ruby</option>
</select>
</div>
<div class="form-group">
<p>Do you like to work on the Front-end or Back-end? <span class="clue">(Check all that apply)</span</p>
<label>
<input name="prefer" value="front-end-projects" type="checkbox" class="input-checkbox" />Front-end
</label>
<label>
<input name="prefer" value="back-end-projects" type="checkbox" class="input-checkbox" />Back-end
</label>
</div>
<div class="form-group">
<p>Please provide any comments if we missed anything?</p>
<textArea id="comments" name="comment" placeholder="Place your comments here..."></textArea>
<div>
<div class="form-group">
<button type="submit" id="submit" class="submit-button">Submit</button>
<div>
</form>
</div>
</div>
try this it:
.container {
display: flex;
justify-content: center;
flex-direction: column;
width: fit-content;
margin: auto;
}
header {
border: 1px solid black;
}
#form {
border: 1px solid black;
}
<div class="container">
<header>
<h1 id="title">Survey Form</h1>
<p id="description">Thank you for helping us improve by taking this survey.</p>
</header>
<div id="form">
<form id="survey-form">
<div class="form-group">
<label id="name-label" for="name">Name</label>
<input type="text" id="name" name="name" placeholder="Enter your name" required>
</div>
<div class="form-group">
<label id="email-label" for="email">Email</label>
<input type="email" id="email" name="email" placeholder="Enter your email" pattern=".+#.+\..+" required>
<div>
<div class="form-group">
<label id="number-label" for="number">Age (optional)</label>
<input type="number" id="number" name="age" placeholder="Enter your email" min="1" max="200" required>
<div class="form-group">
<p>What's your coding experience?</p>
<label>
<input type="radio" name="user-experience" value="noob" class="input-radio" />
Noob
</label>
<label>
<input type="radio" name="user-experience" value="dangerous" class="input-radio" checked/>
Dangerous
</label>
<label>
<input type="radio" name="user-experience" value="veteran" class="input-radio" />
Veteran
</label>
</div>
<div class="form-group">
<p>What programing language do you use the most at work?</p>
<select id="dropdown" class="form-group" name="language" required>
<option disabled selected value>Select a language</option>
<option value="java">Java</option>
<option value="javascript">JavaScript</option>
<option value="python">Python</option>
<option value="c++">C++</option>
<option value="c">C</option>
<option value="c#">C#</option>
<option value="php">PHP</option>
<option value="ruby">Ruby</option>
</select>
</div>
<div class="form-group">
<p>Do you like to work on the Front-end or Back-end? <span class="clue">(Check all that apply)</span</p>
<label>
<input name="prefer" value="front-end-projects" type="checkbox" class="input-checkbox" />Front-end
</label>
<label>
<input name="prefer" value="back-end-projects" type="checkbox" class="input-checkbox" />Back-end
</label>
</div>
<div class="form-group">
<p>Please provide any comments if we missed anything?</p>
<textArea id="comments" name="comment" placeholder="Place your comments here..."></textArea>
<div>
<div class="form-group">
<button type="submit" id="submit" class="submit-button">Submit</button>
<div>
</form>
</div>
</div>
Use flex-flow:column to container
.container {
display: flex;
flex-flow: column;
}
Add style below to header for align content inside the header to center.
header {
align-items: center;
justify-content:center;
display:flex;
flex-flow:column;
}
Try this snippet
.container {
display: flex;
flex-flow: column;
}
header {
border: 1px solid black;
margin-bottom: 10px;
align-items: center;
justify-content:center;
display:flex;
flex-flow:column;
}
#form {
border: 1px solid black;
}
<div class="container">
<header>
<h1 id="title">Survey Form</h1>
<p id="description">Thank you for helping us improve by taking this survey.</p>
</header>
<div id="form">
<form id="survey-form">
<div class="form-group">
<label id="name-label" for="name">Name</label>
<input type="text" id="name" name="name" placeholder="Enter your name" required>
</div>
<div class="form-group">
<label id="email-label" for="email">Email</label>
<input type="email" id="email" name="email" placeholder="Enter your email" pattern=".+#.+\..+" required>
<div>
<div class="form-group">
<label id="number-label" for="number">Age (optional)</label>
<input type="number" id="number" name="age" placeholder="Enter your email" min="1" max="200" required>
<div class="form-group">
<p>What's your coding experience?</p>
<label>
<input type="radio" name="user-experience" value="noob" class="input-radio" />
Noob
</label>
<label>
<input type="radio" name="user-experience" value="dangerous" class="input-radio" checked/>
Dangerous
</label>
<label>
<input type="radio" name="user-experience" value="veteran" class="input-radio" />
Veteran
</label>
</div>
<div class="form-group">
<p>What programing language do you use the most at work?</p>
<select id="dropdown" class="form-group" name="language" required>
<option disabled selected value>Select a language</option>
<option value="java">Java</option>
<option value="javascript">JavaScript</option>
<option value="python">Python</option>
<option value="c++">C++</option>
<option value="c">C</option>
<option value="c#">C#</option>
<option value="php">PHP</option>
<option value="ruby">Ruby</option>
</select>
</div>
<div class="form-group">
<p>Do you like to work on the Front-end or Back-end? <span class="clue">(Check all that apply)</span</p>
<label>
<input name="prefer" value="front-end-projects" type="checkbox" class="input-checkbox" />Front-end
</label>
<label>
<input name="prefer" value="back-end-projects" type="checkbox" class="input-checkbox" />Back-end
</label>
</div>
<div class="form-group">
<p>Please provide any comments if we missed anything?</p>
<textArea id="comments" name="comment" placeholder="Place your comments here..."></textArea>
<div>
<div class="form-group">
<button type="submit" id="submit" class="submit-button">Submit</button>
<div>
</form>
</div>
</div>
HTML registration form is created with gender option and now CSS failed to format radio buttons in table cells. How to put them in a aesthetic format with the help of external stylesheet?
I have tried MDN's guideline to create form and format them using external CSS. MDN suggested with table and table-cell format in the CSS file!
form.form-example {
display: table;
}
div.form-example {
display: table-row;
}
label,
input,
select,
option {
display: table-cell;
margin-bottom: 10px;
}
<form id="registration" action="" , method="post" class="form-example">
<div class="form-example">
<h1>Registration Form</h1>
</div>
<div class="form-example">
<label for="fname">First Name:</label>
<input name="first_name" type="text" id="fname" placeholder="Python" required>
</div>
<div class="form-example">
<label for="lname">Last Name:</label>
<input name="last_name" type="text" id="lname" placeholder="Buddha" required>
</div>
<div class="form-example">
<label for="bdate">Date of Birth:</label>
<input name="dob" type="date" id="bdate">
</div>
<div class="form-example">
<label for="country">Country:</label>
<select name="country" id="country">
<option>USA</option>
<option>Canada</option>
<option>Mexico</option>
</select>
</div>
<div class="form-example">
<label for="email">Email:</label>
<input type="email" id="email" required>
</div>
<div class="form-example">
<label for="password">Password:</label>
<input type="password" id="password" required>
</div>
<div class="form-example">
<label>Gender:</label>
<label for="male">Male</label>
<input type="radio" id="male" name="gender" value="male" required>
<label for="female">Female</label>
<input type="radio" id="female" name="gender" value="female">
<label for="other">Other</label>
<input type="radio" id="other" name="gender" value="other">
</div>
<div class="form-example">
<button>Submit</button>
</div>
</form>
</div>
I would suggest to change your css styles a bit. Because this:
label,input,select,option{
display: table-cell;
margin-bottom: 10px;
}
Will make all inputs on the page to be displayed as a table cell and thus there will be the spacing between radio inputs that you don't like.
I'm sure that there are other options, but what worked for me was removing your label,input,select,option line and adding .table-cell class so you can use it freely on any element that should be displayed as a table-cell.
form.form-example{
display: table;
}
div.form-example{
display: table-row;
height: 30px;
}
.table-cell {
display: table-cell;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="author" content="Kuldeep Gadhavi">
<title>Registration Form</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<form id ="registration" action="", method="post" class="form-example">
<div class="form-example">
<h1>Registration Form</h1>
</div>
<div class="form-example">
<label for="fname" class="table-cell">First Name:</label>
<input name="first_name" type="text" id="fname" placeholder="Python" required class="table-cell">
</div>
<div class="form-example">
<label for="lname" class="table-cell">Last Name:</label>
<input name="last_name" type="text" id="lname" placeholder="Buddha" required class="table-cell">
</div>
<div class="form-example">
<label for="bdate" class="table-cell">Date of Birth:</label>
<input name="dob" clsss="table-cell" type="date" id="bdate">
</div>
<div class="form-example">
<label for="country" class="table-cell">Country:</label>
<select name="country" class="table-cell" id="country">
<option>USA</option>
<option>Canada</option>
<option>Mexico</option>
</select>
</div>
<div class="form-example">
<label for="email" class="table-cell">Email:</label>
<input type="email" id="email" required class="table-cell">
</div>
<div class="form-example">
<label for="password" class="table-cell">Password:</label>
<input type="password" id="password" class="table-cell" required>
</div>
<div class="form-example">
<label class="table-cell">Gender:</label>
<div class="table-cell">
<label for="male">Male</label>
<input type="radio" id="male" name="gender" value="male" required>
<label for="female">Female</label>
<input type="radio" id="female" name="gender" value="female">
<label for="other">Other</label>
<input type="radio" id="other" name="gender" value="other">
</div>
</div>
<div class="form-example table-cell" >
<button>Submit</button>
</div>
</form>
</div>
</body>
</html>
The group with radio buttons is inside a div with class .table-cell therefore only this div will be rendered as a table cell. The radio inputs inside will remain rendered as inline elements and thus there will be no white-space between them. Also don't forget to add .table-cell class to other elements that should be rendered as table cells (so the inputs and labels.. I have also slightly modified the height of the .form-example, because I have removed the margin on .table-cell class.
label,input,select,option{
display: table-cell;
margin-bottom: 10px;
}
This makes every label, input, select and options as cell.
that's why your radio buttons aren't displayed correctly.
you can see that the male, female and other labels are displayed as cell (border property)
removing label tag should fix the problem.
Male
<input type="radio" id="male" name="gender" value="male" checked>
Female
<input type="radio" id="female" name="gender" value="female">
Other
<input type="radio" id="other" name="gender" value="other">
By the way, consider using grid or flex for such things.
I am newcomer in html code so that i have no huge knowledge about html coding.
When I use inline style, it seems to be working fine but the css code inside the head element doesn't show in the web page. The code seems fine to me. I've tried running this code in both Chrome and Firefox, but the problem persists in both of them. Please check my code & give me any advice or solution. Thanks.
fieldset: {
background: lightyellow;
border: 10px solid yellow;
margin-bottom: 10px;
width: 720px;
}
label: {
width: 180px;
}
<h1>Please Enter Your Details For Our Dating Website!</h1>
<form action="https://ihome.ust.hk/~rossiter/cgi-bin/show_everything.php" method="post">
<fieldset>
<legend>Your Face</legend>
<label for="image">Your image:</label>
<input type="file" name="image" required>
<br>
Image preview:
<img src="" id="preview">
</fieldset>
<fieldset>
<legend>Your General Details</legend>
<label for="name">Name:</label>
<input type="text" name="name" required>
<br>
<label for="gender">Gender:</label>
<input type="radio" name="gender" required>
Male
<input type="radio" name="gender" required>
Female
<br>
<label for="age">Age:</label>
<input type="number" name="age" required>
<br>
<label for="dob">Date of birth:</label>
<input type="date" name="dob">
<br>
<label for="color">Favorite color:</label>
<input type="color" name="color">
<br>
<label for="country">Which country:</label>
<select name="country">
<option value="no"></option>
<option value="en">England</option>
<option value="in">India</option>
<option value="jp">Japan</option>
<option value="sp">Spain</option>
<option value="us">USA</option>
</select>
</fieldset>
<fieldset>
<legend>Your Indicators</legend>
<label for="height">Height:</label>
Short
<input type="range" name="height" min="0" max="100">
Tall
<br>
<label for="salary">Salary:</label>
Poor
<input type="range" name="salary" min="0" max="100">
Rich
<br>
</fieldset>
<fieldset>
<legend>Your Contact Information</legend>
<label for="email">Email:</label>
<input type="email" name="email" required>
<br>
<label for="mobile">Mobile:</label>
<input type="tel" name="mobile">
<br>
<label for="address">Address:</label>
<textarea name="address"></textarea>
<br>
<label for="contact">Method to contact you:</label>
<input type="checkbox" name="contact">
Email
<input type="checkbox" name="contact">
Whatsapp
<input type="checkbox" name="contact">
In-app chat
</fieldset>
<input type="submit" name="Submit">
</form>
Remove this "colon :" from styles properties.
fieldset : {
Then others will work fine.
<!DOCTYPE html>
<html>
<head>
<title>Dating Web Site</title>
<style>
fieldset {
background: lightyellow;
border: 10px solid yellow;
margin-bottom: 10px;
width: 720px;
}
label {
width: 180px;
}
</style>
</head>
<body>
<h1>Please Enter Your Details For Our Dating Website!</h1>
<form action="https://ihome.ust.hk/~rossiter/cgi-bin/show_everything.php" method="post">
<fieldset>
<legend>Your Face</legend>
<label for="image">Your image:</label>
<input type="file" name="image" required>
<br>
Image preview:
<img src="" id="preview">
</fieldset>
<fieldset>
<legend>Your General Details</legend>
<label for="name">Name:</label>
<input type="text" name="name" required>
<br>
<label for="gender">Gender:</label>
<input type="radio" name="gender" required>
Male
<input type="radio" name="gender" required>
Female
<br>
<label for="age">Age:</label>
<input type="number" name="age" required>
<br>
<label for="dob">Date of birth:</label>
<input type="date" name="dob">
<br>
<label for="color">Favorite color:</label>
<input type="color" name="color">
<br>
<label for="country">Which country:</label>
<select name="country">
<option value="no"></option>
<option value="en">England</option>
<option value="in">India</option>
<option value="jp">Japan</option>
<option value="sp">Spain</option>
<option value="us">USA</option>
</select>
</fieldset>
<fieldset>
<legend>Your Indicators</legend>
<label for="height">Height:</label>
Short
<input type="range" name="height" min="0" max="100">
Tall
<br>
<label for="salary">Salary:</label>
Poor
<input type="range" name="salary" min="0" max="100">
Rich
<br>
</fieldset>
<fieldset>
<legend>Your Contact Information</legend>
<label for="email">Email:</label>
<input type="email" name="email" required>
<br>
<label for="mobile">Mobile:</label>
<input type="tel" name="mobile">
<br>
<label for="address">Address:</label>
<textarea name="address"></textarea>
<br>
<label for="contact">Method to contact you:</label>
<input type="checkbox" name="contact">
Email
<input type="checkbox" name="contact">
Whatsapp
<input type="checkbox" name="contact">
In-app chat
</fieldset>
<input type="submit" name="Submit">
</form>
</body>
</html>
I was just wondering what shall I do to align the text area in a form so they can be all at the same level.
my code is:
<form method="post" action="process.php" id="contactForm">
<fieldset id="field1">
<div class="subscribe">
<label for="fName">First name:</label>
<input type="text" name="fName" id="fName" required/>
</div>
<div class="subscribe">
<label for="lName">Last name:</label>
<input type="text" name="lName" id="lName" required/>
</div>
<div class="subscribe">
<label for="title">Title:</label>
<select name="title" id="title" required>
<option value="1"> Mr. </option>
<option value="2"> Ms. </option>
<option value="3"> Mrs. </option>
<option value="4"> Miss. </option>
<option value="5"> Master. </option>
</select>
</div>
<div class="subscribe">
<label for="hNumber">Health Authority Number:</label>
<input type="text" name="number" id="hNumber" required/>
</div>
<div class="subscribe">
<label for="email">Email address: </label>
<input type="email" name="email" id="email" required/>
</div>
<div class="subscribe">
<label for="fNr">Telephone number:</label>
<input type="text" name="fNr" id="fNr" required/>
</div>
<div class="button">
<input id="btn1" type="button" value="Submit">
</div>
</fieldsed>
</form>
This CSS code won't do it:
#contactForm {
width: 46em;
padding-top: 0.5em;
padding-bottom: 0.5em;
}
#contactForm label {
padding: 0.5em;
display: inline;
float: center;
}
Thank you for your answers. I know is noobies stuff but it will help me at the minute to get the answer rather then find it out by studying.
Try that:
use inline-block instead;
set a fixed width
delete your padding
I think that's it
#contactForm label {
display: inline-block;
width: 200px;
text-align: left;
}