5 Simple XHTML Web Forms for Web Design

5 Simple XHTML Web Forms for Web Design

Simple XHTML web form in web design 5. Technique 1: Label Sandwich Include the input box, selection box and text box into the label element and set them all as block-level elements. Set the display mode of radio buttons and check boxes to inline so that they appear on the same line. If you prefer the label and radio button/checkbox to appear on different lines, you can choose not to include it in the label, or use hard line break processing.
Each scenario is presented below.

While these seem trendy, the W3C has actually implicitly shown examples of their labels.
Main benefit : Simple code:
label, input, select, textarea {display: block;} label {margin-bottom: 10px;} input[type="radio"], input[type="checkbox"] {display: inline;} <form> <fieldset> <legend>Contact Form</legend> <label for="name"> Name</label> <input id="name" name="name" size="20" /> <label for="email">Email</label> <input id="email" name="email" size="20" /> <label for=" Choices"> Choices (radio) — <em>wrapped label</em></label> <input name=" Choice" type="radio" /> Choice 1 <input name=" Choice" type="radio" /> Choice 2 <input name=" Choice" type="radio" /> Choice 3 <label style="margin-bottom: 0pt;" for=" Choices2"> Choices (checkbox) — <em>non-wrapped label, margin reset</em></label> <input name=" Choice2" type="checkbox" /> Choice 1 <input name=" Choice2" type="checkbox" /> Choice 2 <input name=" Choice2" type="checkbox" /> Choice 3 <div style="height: 10px;"><!-- just to split the demo up --></div> <label for=" Choices3"> Choices (checkbox) — <em>wrapped, hard line-break</em></label> <input name=" Choice3" type="checkbox" /> Choice 1 <input name=" Choice3" type="checkbox" /> Choice 2 <input name=" Choice3" type="checkbox" /> Choice 3 <label for="dropdown"> Question</label> <select id="dropdown"> <optgroup label="Group of Options"></optgroup> <option>Option 1</option> <option>Option 2</option> <option>Option 3</option> </select> <label for="message"> Message <textarea cols="36" rows="12" name="message"></textarea> </label> <input type="submit" value="send it" /> </fieldset> </form>
Running results :
#expamle1 label,#expamle1 input,#expamle1 select,#expamle1 textarea {display: block;}
#expamle1 label {margin-bottom: 10px;}
#expamle1 input[type="radio"],#expamle1 input[type="checkbox"] {display: inline;}
Technique 2: Lazy Many developers use this unorthodox but quick and easy approach (using line breaks to separate tags). It works, but it's bad for your CSS skills, since you don't need any CSS to do it.
Main Benefits : Fast Code:
<form> <fieldset> <legend>Contact Form</legend> <label for="name">Name</label> <input id="name" name="name" size="20" /> <label for="email">Email</label> <input id="email" name="email" size="20" /> <label for=" Choices"> Choices (radio)</label> <input name=" Choice" type="radio" /> Choice 1 <input name=" Choice" type="radio" /> Choice 2 <input name=" Choice" type="radio" /> Choice 3 <label for=" Choices3"> Choices (checkbox)</label> <input name=" Choice3" type="checkbox" /> Choice 1 <input name=" Choice3" type="checkbox" /> Choice 2 <input name=" Choice3" type="checkbox" /> Choice 3 <label for="dropdown">Question</label> <select id="dropdown"> <optgroup label="Group of Options"></optgroup> <option>Option 1</option> <option>Option 2</option> <option>Option 3</option> </select> <label for="message">Message</label> <textarea cols="36" rows="12" name="message"></textarea> <input type="submit" value="send it" /> </fieldset> </form>
Running results :
Previous Page 1 2 Next Page Read Full Article

<<:  Basic usage details of Vue componentization

>>:  The implementation principle of Zabbix dynamic execution monitoring collection script

Recommend

Gearman + MySQL to achieve persistence operation example

This article uses the gearman+mysql method to imp...

How to install JDK8 on Windows

1. Download: http://www.oracle.com/technetwork/ja...

How to force vertical screen on mobile pages

I recently wrote a mobile page at work, which was...

Linux bash: ./xxx: Unable to execute binary file error

Today I sent a small tool for Ubuntu to a custome...

Detailed explanation of Linux host name modification command

Linux change hostname command 1. If you only need...

How to write the style of CSS3 Tianzi grid list

In many projects, it is necessary to implement th...

How to implement Svelte's Defer Transition in Vue

I recently watched Rich Harris's <Rethinki...

Analysis of Linux boot system methods

This article describes how to boot the Linux syst...

How to use Linux paste command

01. Command Overview The paste command will merge...

Let's talk about the performance of MySQL's COUNT(*)

Preface Basically, programmers in the workplace u...

Detailed description of common events and methods of html text

Event Description onactivate: Fired when the objec...

JavaScript to achieve floor effect

This article shares the specific code of JavaScri...

How to deploy python crawler scripts on Linux and set up scheduled tasks

Last year, due to project needs, I wrote a crawle...

How to quickly log in to MySQL database without password under Shell

background When we want to log in to the MySQL da...

Analysis of Vue element background authentication process

Preface: Recently, I encountered a management sys...