Is it better to use <dl> or <ul> for laying out a list of labeled input elements?
-
Is it better to use <dt>label</dt><dd><input/></dd> or <li><label for .../><input/></ll> when laying out a list of labeled input elements? What are the pros and cons of each approach?
-
Answer:
If I have to choose between those two answers - personally I would reserve the definition list for content not form elements as an empty input field does not define a label until it is filled in. What you have is more a list of inputs.
Brian E. McElaney at Quora Visit the source
Other answers
It depends on what you need a list for. Read this for differences between list tags: http://www.mcli.dist.maricopa.edu/tut/tut11.html it has sample code with previews to show difference :::::EDIT (Asker clarified question that I had previously misunderstood::::: Below is 2 From versions you can see the Demos here: http://hakarune.weebly.com/form.html To setup a list with input and a submit button (with and without styling): <html> <head> <title>Form</title> <style type="text/css"> ul{ list-style-type: none; } body, html{ margin:0; padding:0; background:false; } .form-all { padding-top:20px; width:650px; color:Black; font-family:Verdana; font-size:12px; list-style:none; list-style-position:outside; } /* Setting up input styling for al input areas using pure css3 */ .form-all input, .form-all textarea{ padding: 5px; font-size: 15px; text-shadow: 0px 1px 0px #fff; outline: none; background: -webkit-gradient(linear, left top, left bottom, from(#bcbcbe), to(#ffffff)); background: -moz-linear-gradient(top, #bcbcbe, #ffffff); -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; border: 1px solid #717171; -webkit-box-shadow: 1px 1px 0px #efefef; -moz-box-shadow: 1px 1px 0px #efefef; box-shadow: 1px 1px 0px #efefef; } /* Adding on focus change of input style to have glow aound it Pure CSS3 again */ .form-all input:focus, .form-all textarea:focus{ -webkit-box-shadow: 0px 0px 5px #007eff; -moz-box-shadow: 0px 0px 5px #007eff; box-shadow: 0px 0px 5px #007eff; } /* Changing the Style of the button (if you want to use the code only change 'color: rgb(238,238,238);' */ #input_4{ letter-spacing: 1px; display: inline-block; padding: 0.5em 3em; background-color: rgba(255,100,100,0.8); color: rgb(238,238,238); text-decoration: none; font-weight: bold; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; background-image: -moz-linear-gradient(top, rgba(255,255,255,0.25), rgba(255,255,255,0.05)); /* FF3.6 */ background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, rgba(255,255,255,0.25)),color-stop(1, rgba(255,255,255,0.05))); /* Saf4+, Chrome */ text-shadow: rgb(68,68,68) 0 -1px 1px; box-shadow: 1px 1px 3px rgba(68,68,68,0.3); -webkit-box-shadow: 1px 1px 3px rgba(136,136,136,0.3); -moz-box-shadow: 1px 1px 3px rgba(68,68,68,0.3); border-bottom: 1px solid rgba(0,0,0,0.25); } #input_4:hover{ text-shadow: rgb(238,238,238) 0 0 2px; -webkit-transition: all 0.3s linear; } #input_14:active{ background-image: -moz-linear-gradient(top, rgba(255,255,255,0.05),rgba(255,255,255,0.25)); /* FF3.6 */ background-image: -webkit-gradient( linear,left top,left bottom,color-stop(0, rgba(255,255,255,0.05)),color-stop(1, rgba(255,255,255,0.25))); /* Saf4+, Chrome */ border-bottom: 1px solid rgba(0,0,0,0.1); } .form-line{ padding:10px; clear:both; padding:10px; display:inline-block; width:97%; width:-moz-available; } .form-label-top{ margin-bottom:6px; display:inline-block; white-space:normal; } .form-sub-label{ color:#323232; display:block; font-size:10px } .form-sub-label-container{ display:inline-block; margin-right:5px; white-space:nowrap } </style> </head> <body> <!-- Start of form with <form> You should know how to setup the submit action stuff, or google it accept-charset attribute specifies the character-sets the server can handle for form-data --> <form class="form" action="submit.php" method="post" name="contact-form" id="contact" accept-charset="utf-8"> <!-- I use a combo of divs classes and ID's to make it look all cool in the layout, I'll give you a link to view the samble that's here. If you want just the ordered layout with no styling or anything skip down to bottom where there is a form is basic html with no css --> <div class="form-all"> <ul class="form-section"> <li class="form-line"> <label class="form-label-top" id="label_1" for="input_1"> Your Name </label> <div> <span class="form-sub-label-container"> <input class="form-textboxform-textbox" type="text" size="10" name="first-name" id="first_name" /> <label class="form-sub-label" for="first_name" id="sublabel_first"> First Name </label> </span> <span class="form-sub-label-container"> <input class="form-textbox" type="text" size="15" name="last-name" id="last_name" /> <label class="form-sub-label" for="last_name" id="sublabel_last"> Last Name </label></span> </div> </li> <li class="form-line"> <label class="form-label-top" id="label_2" for="input_2"> Your E-mail Address </label> <div id="cid_16" class="form-input-wide"> <input type="email" class="email" id="input_2" name="email" size="20" /> </div> </li> <li class="form-line"> <label class="form-label-top" id="label_3" for="input_3"> Your Message </label> <div id="cid_17" class="form-input-wide"> <textarea id="input_3" class="form-textarea" name="message" cols="60" rows="9"></textarea> </div> </li> <li class="form-line form-line-column"> <div id="cid_4" class="form-input-wide"> <div style="text-align:left"> <button id="input_4" type="submit" class="form-submit-button"> Submit </button> </div> </div> </li> </ul> </div> </form> <br /><br /><br /> <!-- The form below is basic html with no css (except removing bullets) --> <form action="submit.php" method="post" name="contact-form"> <ul> <li> <label for="first_name"> First Name </label> <br /> <input type="text" size="10" name="first-name" /> <br /> <label for="last_name"> Last Name </label> <br /> <input type="text" size="15" name="last-name" /> </li> <li> <label for="input_2"> Your E-mail Address </label> <br /> <input type="email" class="email" id="input_2" name="email" size="20" /> </li> <li> <label for="input_3"> Your Message </label> <br /> <textarea name="message" cols="60" rows="9"></textarea> </li> <li> <button type="submit"> Submit </button> </li> </ul> </form> </body> </html>
Trevor Elliott
Related Q & A:
- Is it better to use many records in one table, or to use multiple tables?Best solution by Stack Overflow
- How to add a list to the existing list jQuery?Best solution by designchemical.com
- Python: How do you get an input from the user into a list?Best solution by stackoverflow.com
- Is it better to use a tv as your computer monitor, or a computer monitor as a tv?Best solution by tomshardware.com
- What kind of camera would be better to use to make youtube videos?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.