Layout a form instance with CSS (discard table)

Source: Internet
Author: User
Tags comments
Css

This is an example of learning web standards, where we typically use tables for form layouts before we use them, and in this case we discard tables to use CSS to lay out the form.


CSS Setup code:

<style type= "Text/css" >

label{
Float:left;
width:120px;
Font-weight:bold;
}

Input, textarea{
width:180px;
margin-bottom:5px;
}

textarea{
width:250px;
height:150px;
}

. boxes{
Width:1em;
}

#submitbutton {
margin-left:120px;
margin-top:5px;
width:90px;
}

br{
Clear:left;
}

</style>

HTML code:

<form>

<label for= "User" >Name</label>
<input type= "text" name= "user" value= "/><br/>

<label for= "EmailAddress" >email address:</label>
<input type= "text" name= "EmailAddress" value= ""/><br/>

<label for= "Comments" >Comments:</label>
<textarea name= "Comments" ></textarea><br/>

<label for= "terms" >agree to terms?</label>
<input type= "checkbox" name= "terms" class= "boxes"/><br/>

<input type= "Submit" Name= "Submitbutton" id= "Submitbutton" value= "Submit"/>

</form>

In this example, the "label" label to layout the left part of the form, that is, the form's hints, so that the effect of the form display is divided into about two parts, the width of the left we can use the "label" label to Control.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.