css This is a layout test made yesterday! I feel that the form layout is very troublesome, and it is more difficult to solve the problem with the least code!
This is an example. I don't know if there is a better solution. Post it here and just look at it!
Program code body {font-size: 12px; line-height: 1.9; text-align: center;}
#info {border: 1px solid # 006699; background: # F9EBBB; text-align: left; margin: 10px auto; width: 300px; padding: 10px 10px 10px 110px;}
#info label {width: 100px; display: block; float: left; text-align: right; margin-left: -100px! important; margin-left: -50px;}
#info input {border: 1px solid # 666699; height: 19px;}
#info h1 {font-size: 12px; margin: 0px;}
#info em {color: # FF0000; padding: 0 5px;}
#info div {color: # FF0000; border: 1px solid # FF0000; padding: 0 5px; background: # FCF9E2; margin: 2px 0; width: 140px;}
.bx {margin: 3px;}
Program code <div id = "info">
<h1> A test of form layout </ h1>
<label> Your name: </ label>
<input name = "" type = "text" />
<em> * </ em> This is required! <br />
<label> </ label>
<div> The username is invalid! </ div>
<label> Email: </ label>
<input name = "" type = "text" />
<em> * </ em> This is required! <br />
<label> </ label>
<div> Email error! </ div>
<label> Address: </ label>
<input name = "" type = "text" />
<em> * </ em> This is required! <br />
<label> URL: </ label>
<input name = "" type = "text" />
<em> * </ em> This is required! <br />
<input type = "button" class = "bx" value = "submit" />
</ div>
HTML code
<! DOCTYPEhtml PUBLIC "-/ W3C // DTD XHTML 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns = "http: //www.w3.org/1999/xhtml"><head><meta http-equiv = "Content-Type" content = "text / html; charset = utf-8" /> <title> Form example </ title > <style> / * zishu.cn * / body {font-size: 12px; line-height: 1.9; text-align: center;} # info {border: 1px solid # 006699; background: # F9EBBB; text-align : left; margin: 10px auto; width: 300px; padding: 10px 10px 10px 110px;) # info label {width: 100px; display: block; float: left; text-align: right; margin-left: -100px! important ; margin-left: -50px;} # info input {border: 1px solid # 666699; height: 19px;} # info h1 {font-size: 12px; margin: 0px;} # info em {color: # FF0000; padding : 0 5px;} # info div {color: # FF0000; border: 1px solid # FF0000; padding: 0 5px; background: # FCF9E2; margin: 2px 0; width: 140px;}. Bx {margin: 3px;} < / style> </ head> <body> <div id = "info"> <h1> A test of form layout </ h1> <label> Your name: </ label> <input name = "" type = " text "/> <em> * </ em> This is required Fill it out! <br /> <label> </ label> <div> The username is invalid! </ div> <label> Email: </ label> <input name = "" type = "text" /> <em> * </ em> This is required! <br /> <label> </ label> <div> Email error! </ div> <label> Address: </ label> <inputname = "" type = "text" /> <em> * </ em> This is required! <br /> <label> URL: </ label> <input name = "" type = "text" /> <em> * </ em> This is required! <br /> <input type = "button" class = "bx" value = "submit" </ div> </ body> </ html>