This is my code so far:
<form>
<p>Username: </p><input type="text" name="username" />
<p>Password: </p><input type="text" name="password" />
<br /><input type="submit" value="Submit" />
</form>
For some interesting reason it is going to another line for ever paragraph and textbox. What can I do to prevent that?
Put your paragraph tags around the input also. The P tag basically does a line break at the end of itself.
<form>
<p>Username: <input type="text" name="username" /></p>
<p>Password: <input type="text" name="password" /></p>
<br /><input type="submit" value="Submit" />
</form>
Do this:
<form>
Username: <input type="text" name="username" />
<br/>
Password: <input type="text" name="password" />
<br /><input type="submit" value="Submit" />
</form>
or
<form>
Username:<br/> <input type="text" name="username" />
<br/>
Password:<br/> <input type="text" name="password" />
<br /><input type="submit" value="Submit" />
</form>
<form>
<div style="float: left;">Username: <input type="text" name="username" /></div>
<div style="float: left;">Password: <input type="text" name="password" /></div>
<div style="clear: both;"></div>
<input type="submit" value="Submit" />
</form>
They're dropping to a new line because of your markup. Paragraph (<p>) tags drop to a new line, as do breaks (<br>). I would suggest using <span> tags in place of the paragraph tags, and remove the line break.
p tag is by default "display: block" which means a <br /> before and after p is added by the browser, so is the reason it is going to the next line.
include both the label & textbox in "p"
<form>
<p>Username: <input type="text" name="username" /></p>
<p>Password: <input type="text" name="password" /></p>
<p><input type="submit" value="Submit" /></p>
</form>
Related
I'm an absolute beginner & would be grateful to know how to position an input type button in a form not to move on re sizing my browser.
<form action="HereYouGo.php" method="post">
<center>
<p>
<input type="text" name="fullname" size="25" />
<input type="text" name="email" size="25" />
<input type="password" name="psw" size="25" />
</p>
</center>
<p>
<input type="submit" value="Here You Go!" />
</p>
<center>
<h4>By clicking "Here You Go!" you agree with our terms & conditions and private policy.</h4>
</center>
</form>
I want the register button to be in same line as login but it wont work when it is placed outside of the form.
<div style="float:right;min-width:440px;width:30%;padding-top:30px;">
<form>
Username:<input name="username" type="text" name="username" style="min-width:120px;"></input>
Password:<input name="password" type="text" name="password" style="min-width:120px;"></input>
<input type="submit" value="Login"></input>
</form>
<button>Register</button>
</div>
Deried from Vitorino Fernandes' comment. Try following -
<div style="float:right;min-width:440px;width:30%;padding-top:30px;">
<form>
Username:<input name="username" type="text" name="username" style="min-width:120px;"></input><br />
Password:<input name="password" type="text" name="password" style="min-width:120px;"></input>
<br /> <input type="submit" value="Login"></input>
</form>
<button style="position:absolute; left:140px; top:80px">Register</button>
</div>
I'm guessing that you want to put the button outside the form since you don't want to submit the form on clicking the Register button.
This can be achieved by keeping the register button inside the form - use this for the register button:
<input type="button" value="Register"></input>
Check this JSFiddle. The form will submit on clicking the login button but it won't submit on clicking the register button.
Also see: Difference between <input type='button' /> and <input type='submit' />
Try This : JSFIDDLE
<div style="float:right;min-width:565px;width:30%;padding-top:30px;">
<form style="float:left">
Username:<input name="username" type="text" name="username" style="min-width:120px;"></input>
Password:<input name="password" type="text" name="password" style="min-width:120px;"></input>
<input type="submit" value="Login"></input>
</form>
<button style="float:left">Register</button>
</div>
This is driving me crazy. I know its something to do with the label tag. here is my code:
<form method="post" action="includes/loginprocess.php">
<label for="username">Username: </label>
<input type="text" name="username" value=''/>
<label for="password">Password: </label>
<input type="password" name="password" />
<input type="submit" name="submit" value="submit" />
</form>
The for and name are both the same?
The error is "The for attribute of the label element must refer to a form control."
According to http://www.w3schools.com/tags/att_label_for.asp, the value of for attribute of a label should be the id of the element the label is bound to, so add id attribute to the textboxes
<form method="post" action="includes/loginprocess.php">
<label for="username">Username: </label>
<input type="text" name="username" id="username" value=''/>
<label for="password">Password: </label>
<input type="password" name="password" id="password" />
<input type="submit" name="submit" value="submit" />
</form>
I am using placeholders for all my form elements and it's showing up in them all apart from the textarea. Just looked at it in safari now, and have realised that my input of type="number" isn't showing the placeholder either.
The page is here and you need to click the 'book now' link at the top of the page.
My html:
<form id="booking" action="single-workshops.php">
<input type="text" required="required" placeholder="name"/><br />
<input type="text" required="required" placeholder="your phone number"/><br />
<input type="email" required="required" placeholder="email"/><br />
<input type="number" required="required" placeholder="how many in your party" /><br />
<textarea rows="5" cols="30" placeholder="enter optional message">
</textarea><br />
<input type="button" value="submit"/>
</form>
Because you have something as text in your textarea with a linebreak in it.
<textarea rows="5" cols="30" placeholder="enter optional message">
</textarea><br />
Should be:
<textarea rows="5" cols="30" placeholder="enter optional message"></textarea><br />
I want this form band button to line up horizontally and to sit as a whole in the horizontal center of the page.
How do I set my css?
<form action="signup.php" method="post">
<fieldset>
<label>Email: <label>
<input type="text" name="email" id="email" placeholder='email address' />
<input type="submit" value="Sign Up" class= "button" />
</fieldset>
</form>
Plenty of ways to tackle this. Here is one solution. Though, I do recommend not using inline styles, but here is your form with the CSS.
<form action="signup.php" method="post" style="margin: 0 auto; width: 350px;">
<fieldset>
<label>Email: <label>
<input type="text" name="email" id="email" placeholder='email address' />
<input type="submit" value="Sign Up" class= "button" />
</fieldset>
</form>
I would wrap your inputs in a div and set the div to display:inline in your css. In your css also target your form and set that to margin:auto
something like this:
<div style="width: 300px; margin-left: auto; margin-right:auto;">
<form action="signup.php" method="post">
<fieldset>
<label>Email: <label>
<input type="text" name="email" id="email" placeholder='email address' />
<input type="submit" value="Sign Up" class= "button" />
</fieldset>
</form>
</div>