Error in HTML form when using <label> tag -
i making web form have working , trying style using css before building site it. have found after adding label tags getting errors when click on box jumps first name box, way fill out form use tab.
my html:
<label> <form action="register keys site/form.php" method="post"> first name: <input type="text" name="first_name"><br> last name: <input type="text" name="last_name"><br> email: <input type="text" name="email"><br> phone number: <input type="text" name="phonenumber"><br> information on key: <input type="text" name="keyinfo"><br> password: <input type="text" name="password"><br> password hint: <input type="text" name="passwordhint"><br> <textarea rows="5" name="message" cols="30" placeholder="please add additional comments here"></textarea><br> <input type="submit" name="submit" value="submit"> </form> </label>
css:
label { float: left; text-align: right; margin-right: 15px; width: 300px; } input { border:0; padding:5px; font-size:0.7em; color:#aaa; border:solid 1px #ccc; margin:0 0 5px; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; width: 160px ; } textarea { border:0; padding:5px; font-size:0.7em; color:#aaa; border:solid 1px #ccc; margin:0 0 5px; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; width: 160px ; } input:focus { border:solid 1px #eea34a; }
you have wrapped form
element inside label
element. that’s invalid markup , has strange effects. see @verdesrobert’s answer adequate use of label
. , should use label
way, reasons of functionality.
but trying do, styling of form whole, can done setting css properties on form
element. example:
form { float: left; text-align: right; margin-right: 15px; width: 300px; }
(to use styling. not recommend setting width , indentation in pixels in em
units.)
Comments
Post a Comment