CINXE.COM

HTML Form Code

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="keywords" content="html form codes, code, forms, free, input, select, dropdown, submit"> <meta name="Description" content="Create a form within your HTML codes."> <link rel="canonical" href="https://www.quackit.com/html/codes/html_form_code.cfm"> <title>HTML Form Code</title> <script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <link rel="shortcut icon" href="/pix/favicon96.png"> <link rel="apple-touch-icon" href="/pix/apple-touch-icon.png"> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;1,400&display=swap" rel="stylesheet"> <link href="/common/css/master.45.min.css" rel="stylesheet"> <script async src="https://cdn.fuseplatform.net/publift/tags/2/3499/fuse.js"></script> <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-Q3H025ZKLN"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-Q3H025ZKLN'); </script> </head> <body> <header class="site-header"> <div class="site-header-base"> <div class="site-logo"> <a title="Quackit Homepage" target="_top" href="/"><img src="/pix/quackit_logo_watermark.png" width="87" height="33" alt="Quackit Logo"></a> </div> <button id="site-nav-toggler" class="site-nav-toggler" aria-expanded="false" aria-controls="site-nav"> <span class="sr-only">Toggle navigation</span> &#9776; </button> </div> <nav id="site-nav" class="site-nav"> <div class="site-links"> <ul> <li><a href="/"><i class="fa fa-home"></i> <span class="sr-only">Home</span></a></li> <li><a href="/html/">HTML</a></li> <li><a href="/css/">CSS</a></li> <li><a href="/scripting/">Scripting</a></li> <li><a href="/database/">Database</a></li> </ul> </div> <div class="site-search-top"> <form action="/search/" id="cse-search-box-bottom" class="site-search"> <div> <input type="hidden" name="cx" value="partner-pub-6331358926293806:98x0fk-bbgi"> <input type="hidden" name="cof" value="FORID:10"> <input type="hidden" name="ie" value="ISO-8859-1"> <input type="text" name="q" size="20" class="site-search-input"> <button type="submit" name="sa" class="site-search-button"><i class="fa fa-search"></i></button> </div> </form> </div> </nav> </header> <div class="main"> <article class="content"> <h1 class="page-title">HTML Form Code</h1> <div class="ad ad-top"> <!-- GAM 71161633/QCKIT_quackit/article_header --> <div data-fuse="23059883623"></div> </div> <p class="lead">You can use the following HTML code to create a form within your HTML document. </p> <div class="ad"> <!-- GAM 71161633/QCKIT_quackit/article_incontent_1 --> <div data-fuse="23059883629"></div> </div> <h2>Example Form with No Styles</h2> <p>This example uses raw <a href="/html/">HTML</a> &mdash; no <code>CSS</code> has been applied.</p> <script src="/common/js/codemirror/lib/codemirror.js"></script> <script src="/common/js/codemirror/mode/htmlmixed/htmlmixed.js"></script> <script src="/common/js/codemirror/mode/css/css.js"></script> <script src="/common/js/codemirror/mode/javascript/javascript.js"></script> <script src="/common/js/codemirror/mode/xml/xml.js"></script> <div class="code-only"> <textarea id="example1" autocomplete="off" spellcheck="false">&lt;form method&#x3d;&quot;get&quot; action&#x3d;&quot;&#x2f;html&#x2f;form_handler.cfm&quot;&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Name&#xa;&lt;input type&#x3d;&quot;text&quot; name&#x3d;&quot;customer_name&quot; required&gt;&#xa;&lt;&#x2f;label&gt; &#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Phone &#xa;&lt;input type&#x3d;&quot;tel&quot; name&#x3d;&quot;phone_number&quot;&gt;&#xa;&lt;&#x2f;label&gt;&#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Email &#xa;&lt;input type&#x3d;&quot;email&quot; name&#x3d;&quot;email_address&quot;&gt;&#xa;&lt;&#x2f;label&gt;&#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;fieldset&gt;&#xa;&lt;legend&gt;Which taxi do you require&#x3f;&lt;&#x2f;legend&gt;&#xa;&lt;p&gt;&lt;label&gt; &lt;input type&#x3d;&quot;radio&quot; name&#x3d;&quot;taxi&quot; required value&#x3d;&quot;car&quot;&gt; Car &lt;&#x2f;label&gt;&lt;&#x2f;p&gt;&#xa;&lt;p&gt;&lt;label&gt; &lt;input type&#x3d;&quot;radio&quot; name&#x3d;&quot;taxi&quot; required value&#x3d;&quot;van&quot;&gt; Van &lt;&#x2f;label&gt;&lt;&#x2f;p&gt;&#xa;&lt;p&gt;&lt;label&gt; &lt;input type&#x3d;&quot;radio&quot; name&#x3d;&quot;taxi&quot; required value&#x3d;&quot;tuktuk&quot;&gt; Tuk Tuk &lt;&#x2f;label&gt;&lt;&#x2f;p&gt;&#xa;&lt;&#x2f;fieldset&gt;&#xa;&#xa;&lt;fieldset&gt;&#xa;&lt;legend&gt;Extras&lt;&#x2f;legend&gt;&#xa;&lt;p&gt;&lt;label&gt; &lt;input type&#x3d;&quot;checkbox&quot; name&#x3d;&quot;extras&quot; value&#x3d;&quot;baby&quot;&gt; Baby Seat &lt;&#x2f;label&gt;&lt;&#x2f;p&gt;&#xa;&lt;p&gt;&lt;label&gt; &lt;input type&#x3d;&quot;checkbox&quot; name&#x3d;&quot;extras&quot; value&#x3d;&quot;wheelchair&quot;&gt; Wheelchair Access &lt;&#x2f;label&gt;&lt;&#x2f;p&gt;&#xa;&lt;p&gt;&lt;label&gt; &lt;input type&#x3d;&quot;checkbox&quot; name&#x3d;&quot;extras&quot; value&#x3d;&quot;tip&quot;&gt; Stock Tip &lt;&#x2f;label&gt;&lt;&#x2f;p&gt;&#xa;&lt;&#x2f;fieldset&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Pickup Date&#x2f;Time&#xa;&lt;input type&#x3d;&quot;datetime-local&quot; name&#x3d;&quot;pickup_time&quot; required&gt;&#xa;&lt;&#x2f;label&gt;&#xa;&lt;&#x2f;p&gt;&#xa;&#x9;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Pickup Place&#xa;&lt;select id&#x3d;&quot;pickup_place&quot; name&#x3d;&quot;pickup_place&quot;&gt;&#xa;&lt;option value&#x3d;&quot;&quot; selected&#x3d;&quot;selected&quot;&gt;Select One&lt;&#x2f;option&gt;&#xa;&lt;option value&#x3d;&quot;office&quot; &gt;Taxi Office&lt;&#x2f;option&gt;&#xa;&lt;option value&#x3d;&quot;town_hall&quot; &gt;Town Hall&lt;&#x2f;option&gt;&#xa;&lt;option value&#x3d;&quot;telepathy&quot; &gt;We&#x27;ll Guess&#x21;&lt;&#x2f;option&gt;&#xa;&lt;&#x2f;select&gt;&#xa;&lt;&#x2f;label&gt; &#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Dropoff Place&#xa;&lt;input type&#x3d;&quot;text&quot; name&#x3d;&quot;dropoff_place&quot; required list&#x3d;&quot;destinations&quot;&gt;&#xa;&lt;&#x2f;label&gt;&#xa;&#xa;&lt;datalist id&#x3d;&quot;destinations&quot;&gt;&#xa;&lt;option value&#x3d;&quot;Airport&quot;&gt;&#xa;&lt;option value&#x3d;&quot;Beach&quot;&gt;&#xa;&lt;option value&#x3d;&quot;Fred Flinstone&#x27;s House&quot;&gt;&#xa;&lt;&#x2f;datalist&gt;&#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Special Instructions&#xa;&lt;textarea name&#x3d;&quot;comments&quot; maxlength&#x3d;&quot;500&quot;&gt;&lt;&#x2f;textarea&gt;&#xa;&lt;&#x2f;label&gt;&#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;p&gt;&lt;button&gt;Submit Booking&lt;&#x2f;button&gt;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;&#x2f;form&gt;</textarea> <p> <a class="btn btn-default" href="/html/html_editors/scratchpad/?example=/html/codes/html_form_code" target="_blank" title="Full-page editor. Opens this example in the full-page editor."><i class="fa fa-pencil-square-o"></i> View Output</i></a> </p> </div> <script> var exampleCode1 = CodeMirror.fromTextArea(document.getElementById("example1"), { mode: "htmlmixed", tabMode: "indent", styleActiveLine: false, lineNumbers: false, lineWrapping: true, theme: "q-dark" }); </script> <h2>Same Form Styled with Top-Aligned Labels</h2> <p>This is the same form, but this one has CSS applied to ensure the labels appear above the input fields. Some other light styling has also been appled.</p> <script src="/common/js/codemirror/mode/htmlmixed/htmlmixed.js"></script> <div class="code-only"> <textarea id="example2" autocomplete="off" spellcheck="false">&lt;&#x21;DOCTYPE html&gt;&#xa;&lt;html lang&#x3d;&quot;en&quot;&gt;&#xa;&lt;head&gt;&#xa;&lt;meta charset&#x3d;&quot;utf-8&quot;&gt;&#xa;&lt;meta name&#x3d;&quot;viewport&quot; content&#x3d;&quot;width&#x3d;device-width, initial-scale&#x3d;1&quot;&gt;&#xa;&lt;meta http-equiv&#x3d;&quot;x-ua-compatible&quot; content&#x3d;&quot;ie&#x3d;edge&quot;&gt;&#xa;&lt;title&gt;My Example&lt;&#x2f;title&gt;&#xa;&#xa;&lt;&#x21;-- CSS --&gt;&#xa;&lt;style&gt;&#xa;.myForm &#x7b;&#xa;font-family&#x3a; &quot;Lucida Sans Unicode&quot;, &quot;Lucida Grande&quot;, sans-serif&#x3b;&#xa;font-size&#x3a; 0.8em&#x3b;&#xa;width&#x3a; 20em&#x3b;&#xa;padding&#x3a; 1em&#x3b;&#xa;border&#x3a; 1px solid &#x23;ccc&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm &#x2a; &#x7b;&#xa;box-sizing&#x3a; border-box&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm fieldset &#x7b;&#xa;border&#x3a; none&#x3b;&#xa;padding&#x3a; 0&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm legend,&#xa;.myForm label &#x7b;&#xa;padding&#x3a; 0&#x3b;&#xa;font-weight&#x3a; bold&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm label.choice &#x7b;&#xa;font-size&#x3a; 0.9em&#x3b;&#xa;font-weight&#x3a; normal&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm input&#x5b;type&#x3d;&quot;text&quot;&#x5d;,&#xa;.myForm input&#x5b;type&#x3d;&quot;tel&quot;&#x5d;,&#xa;.myForm input&#x5b;type&#x3d;&quot;email&quot;&#x5d;,&#xa;.myForm input&#x5b;type&#x3d;&quot;datetime-local&quot;&#x5d;,&#xa;.myForm select,&#xa;.myForm textarea &#x7b;&#xa;display&#x3a; block&#x3b;&#xa;width&#x3a; 100&#x25;&#x3b;&#xa;border&#x3a; 1px solid &#x23;ccc&#x3b;&#xa;font-family&#x3a; &quot;Lucida Sans Unicode&quot;, &quot;Lucida Grande&quot;, sans-serif&#x3b;&#xa;font-size&#x3a; 0.9em&#x3b;&#xa;padding&#x3a; 0.3em&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm textarea &#x7b;&#xa;height&#x3a; 100px&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm button &#x7b;&#xa;padding&#x3a; 1em&#x3b;&#xa;border-radius&#x3a; 0.5em&#x3b;&#xa;background&#x3a; &#x23;eee&#x3b;&#xa;border&#x3a; none&#x3b;&#xa;font-weight&#x3a; bold&#x3b;&#xa;margin-top&#x3a; 1em&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm button&#x3a;hover &#x7b;&#xa;background&#x3a; &#x23;ccc&#x3b;&#xa;cursor&#x3a; pointer&#x3b;&#xa;&#x7d;&#xa;&lt;&#x2f;style&gt;&#xa;&#xa;&lt;&#x2f;head&gt;&#xa;&lt;body&gt;&#xa;&#xa;&lt;form class&#x3d;&quot;myForm&quot; method&#x3d;&quot;get&quot; action&#x3d;&quot;&#x2f;html&#x2f;form_handler.cfm&quot;&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Name&#xa;&lt;input type&#x3d;&quot;text&quot; name&#x3d;&quot;customer_name&quot; required&gt;&#xa;&lt;&#x2f;label&gt; &#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Phone &#xa;&lt;input type&#x3d;&quot;tel&quot; name&#x3d;&quot;phone_number&quot;&gt;&#xa;&lt;&#x2f;label&gt;&#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Email &#xa;&lt;input type&#x3d;&quot;email&quot; name&#x3d;&quot;email_address&quot;&gt;&#xa;&lt;&#x2f;label&gt;&#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;fieldset&gt;&#xa;&lt;legend&gt;Which taxi do you require&#x3f;&lt;&#x2f;legend&gt;&#xa;&lt;p&gt;&lt;label class&#x3d;&quot;choice&quot;&gt; &lt;input type&#x3d;&quot;radio&quot; name&#x3d;&quot;taxi&quot; required value&#x3d;&quot;car&quot;&gt; Car &lt;&#x2f;label&gt;&lt;&#x2f;p&gt;&#xa;&lt;p&gt;&lt;label class&#x3d;&quot;choice&quot;&gt; &lt;input type&#x3d;&quot;radio&quot; name&#x3d;&quot;taxi&quot; required value&#x3d;&quot;van&quot;&gt; Van &lt;&#x2f;label&gt;&lt;&#x2f;p&gt;&#xa;&lt;p&gt;&lt;label class&#x3d;&quot;choice&quot;&gt; &lt;input type&#x3d;&quot;radio&quot; name&#x3d;&quot;taxi&quot; required value&#x3d;&quot;tuktuk&quot;&gt; Tuk Tuk &lt;&#x2f;label&gt;&lt;&#x2f;p&gt;&#xa;&lt;&#x2f;fieldset&gt;&#xa;&#xa;&lt;fieldset&gt;&#xa;&lt;legend&gt;Extras&lt;&#x2f;legend&gt;&#xa;&lt;p&gt;&lt;label class&#x3d;&quot;choice&quot;&gt; &lt;input type&#x3d;&quot;checkbox&quot; name&#x3d;&quot;extras&quot; value&#x3d;&quot;baby&quot;&gt; Baby Seat &lt;&#x2f;label&gt;&lt;&#x2f;p&gt;&#xa;&lt;p&gt;&lt;label class&#x3d;&quot;choice&quot;&gt; &lt;input type&#x3d;&quot;checkbox&quot; name&#x3d;&quot;extras&quot; value&#x3d;&quot;wheelchair&quot;&gt; Wheelchair Access &lt;&#x2f;label&gt;&lt;&#x2f;p&gt;&#xa;&lt;p&gt;&lt;label class&#x3d;&quot;choice&quot;&gt; &lt;input type&#x3d;&quot;checkbox&quot; name&#x3d;&quot;extras&quot; value&#x3d;&quot;tip&quot;&gt; Stock Tip &lt;&#x2f;label&gt;&lt;&#x2f;p&gt;&#xa;&lt;&#x2f;fieldset&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Pickup Date&#x2f;Time&#xa;&lt;input type&#x3d;&quot;datetime-local&quot; name&#x3d;&quot;pickup_time&quot; required&gt;&#xa;&lt;&#x2f;label&gt;&#xa;&lt;&#x2f;p&gt;&#xa;&#x9;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Pickup Place&#xa;&lt;select id&#x3d;&quot;pickup_place&quot; name&#x3d;&quot;pickup_place&quot;&gt;&#xa;&lt;option value&#x3d;&quot;&quot; selected&#x3d;&quot;selected&quot;&gt;Select One&lt;&#x2f;option&gt;&#xa;&lt;option value&#x3d;&quot;office&quot; &gt;Taxi Office&lt;&#x2f;option&gt;&#xa;&lt;option value&#x3d;&quot;town_hall&quot; &gt;Town Hall&lt;&#x2f;option&gt;&#xa;&lt;option value&#x3d;&quot;telepathy&quot; &gt;We&#x27;ll Guess&#x21;&lt;&#x2f;option&gt;&#xa;&lt;&#x2f;select&gt;&#xa;&lt;&#x2f;label&gt; &#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Dropoff Place&#xa;&lt;input type&#x3d;&quot;text&quot; name&#x3d;&quot;dropoff_place&quot; required list&#x3d;&quot;destinations&quot;&gt;&#xa;&lt;&#x2f;label&gt;&#xa;&#xa;&lt;datalist id&#x3d;&quot;destinations&quot;&gt;&#xa;&lt;option value&#x3d;&quot;Airport&quot;&gt;&#xa;&lt;option value&#x3d;&quot;Beach&quot;&gt;&#xa;&lt;option value&#x3d;&quot;Fred Flinstone&#x27;s House&quot;&gt;&#xa;&lt;&#x2f;datalist&gt;&#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Special Instructions&#xa;&lt;textarea name&#x3d;&quot;comments&quot; maxlength&#x3d;&quot;500&quot;&gt;&lt;&#x2f;textarea&gt;&#xa;&lt;&#x2f;label&gt;&#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;p&gt;&lt;button&gt;Submit Booking&lt;&#x2f;button&gt;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;&#x2f;form&gt;&#xa;&#xa;&lt;&#x2f;body&gt;&#xa;&lt;&#x2f;html&gt;</textarea> <p> <a class="btn btn-default" href="/html/html_editors/scratchpad/?example=/html/codes/html_form_code_top_aligned_labels" target="_blank" title="Full-page editor. Opens this example in the full-page editor."><i class="fa fa-pencil-square-o"></i> View Output</i></a> </p> </div> <script> var exampleCode2 = CodeMirror.fromTextArea(document.getElementById("example2"), { mode: "htmlmixed", tabMode: "indent", styleActiveLine: false, lineNumbers: false, lineWrapping: true, theme: "q-dark" }); </script> <h2>Left-Aligned Labels</h2> <p>This form has left-aligned labels.</p> <div class="code-only"> <textarea id="example3" autocomplete="off" spellcheck="false">&lt;&#x21;DOCTYPE html&gt;&#xa;&lt;html lang&#x3d;&quot;en&quot;&gt;&#xa;&lt;head&gt;&#xa;&lt;meta charset&#x3d;&quot;utf-8&quot;&gt;&#xa;&lt;meta name&#x3d;&quot;viewport&quot; content&#x3d;&quot;width&#x3d;device-width, initial-scale&#x3d;1&quot;&gt;&#xa;&lt;meta http-equiv&#x3d;&quot;x-ua-compatible&quot; content&#x3d;&quot;ie&#x3d;edge&quot;&gt;&#xa;&lt;title&gt;My Example&lt;&#x2f;title&gt;&#xa;&#xa;&lt;&#x21;-- CSS --&gt;&#xa;&lt;style&gt;&#xa;.myForm &#x7b;&#xa;font-family&#x3a; &quot;Lucida Sans Unicode&quot;, &quot;Lucida Grande&quot;, sans-serif&#x3b;&#xa;font-size&#x3a; 0.8em&#x3b;&#xa;width&#x3a; 30em&#x3b;&#xa;padding&#x3a; 1em&#x3b;&#xa;border&#x3a; 1px solid &#x23;ccc&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm &#x2a; &#x7b;&#xa;box-sizing&#x3a; border-box&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm fieldset &#x7b;&#xa;border&#x3a; none&#x3b;&#xa;padding&#x3a; 0&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm legend,&#xa;.myForm label &#x7b;&#xa;padding&#x3a; 0&#x3b;&#xa;font-weight&#x3a; bold&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm label.choice &#x7b;&#xa;font-size&#x3a; 0.9em&#x3b;&#xa;font-weight&#x3a; normal&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm label &#x7b;&#xa;text-align&#x3a; left&#x3b;&#xa;display&#x3a; block&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm input&#x5b;type&#x3d;&quot;text&quot;&#x5d;,&#xa;.myForm input&#x5b;type&#x3d;&quot;tel&quot;&#x5d;,&#xa;.myForm input&#x5b;type&#x3d;&quot;email&quot;&#x5d;,&#xa;.myForm input&#x5b;type&#x3d;&quot;datetime-local&quot;&#x5d;,&#xa;.myForm select,&#xa;.myForm textarea &#x7b;&#xa;float&#x3a; right&#x3b;&#xa;width&#x3a; 60&#x25;&#x3b;&#xa;border&#x3a; 1px solid &#x23;ccc&#x3b;&#xa;font-family&#x3a; &quot;Lucida Sans Unicode&quot;, &quot;Lucida Grande&quot;, sans-serif&#x3b;&#xa;font-size&#x3a; 0.9em&#x3b;&#xa;padding&#x3a; 0.3em&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm textarea &#x7b;&#xa;height&#x3a; 100px&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm input&#x5b;type&#x3d;&quot;radio&quot;&#x5d;,&#xa;.myForm input&#x5b;type&#x3d;&quot;checkbox&quot;&#x5d; &#x7b;&#xa;margin-left&#x3a; 40&#x25;&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm button &#x7b;&#xa;padding&#x3a; 1em&#x3b;&#xa;border-radius&#x3a; 0.5em&#x3b;&#xa;background&#x3a; &#x23;eee&#x3b;&#xa;border&#x3a; none&#x3b;&#xa;font-weight&#x3a; bold&#x3b;&#xa;margin-left&#x3a; 40&#x25;&#x3b;&#xa;margin-top&#x3a; 1.8em&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm button&#x3a;hover &#x7b;&#xa;background&#x3a; &#x23;ccc&#x3b;&#xa;cursor&#x3a; pointer&#x3b;&#xa;&#x7d;&#xa;&lt;&#x2f;style&gt;&#xa;&#xa;&lt;&#x2f;head&gt;&#xa;&lt;body&gt;&#xa;&#xa;&lt;form class&#x3d;&quot;myForm&quot; method&#x3d;&quot;get&quot; action&#x3d;&quot;&#x2f;html&#x2f;form_handler.cfm&quot;&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Name&#xa;&lt;input type&#x3d;&quot;text&quot; name&#x3d;&quot;customer_name&quot; required&gt;&#xa;&lt;&#x2f;label&gt; &#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Phone &#xa;&lt;input type&#x3d;&quot;tel&quot; name&#x3d;&quot;phone_number&quot;&gt;&#xa;&lt;&#x2f;label&gt;&#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Email &#xa;&lt;input type&#x3d;&quot;email&quot; name&#x3d;&quot;email_address&quot;&gt;&#xa;&lt;&#x2f;label&gt;&#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;fieldset&gt;&#xa;&lt;legend&gt;Which taxi do you require&#x3f;&lt;&#x2f;legend&gt;&#xa;&lt;p&gt;&lt;label class&#x3d;&quot;choice&quot;&gt; &lt;input type&#x3d;&quot;radio&quot; name&#x3d;&quot;taxi&quot; required value&#x3d;&quot;car&quot;&gt; Car &lt;&#x2f;label&gt;&lt;&#x2f;p&gt;&#xa;&lt;p&gt;&lt;label class&#x3d;&quot;choice&quot;&gt; &lt;input type&#x3d;&quot;radio&quot; name&#x3d;&quot;taxi&quot; required value&#x3d;&quot;van&quot;&gt; Van &lt;&#x2f;label&gt;&lt;&#x2f;p&gt;&#xa;&lt;p&gt;&lt;label class&#x3d;&quot;choice&quot;&gt; &lt;input type&#x3d;&quot;radio&quot; name&#x3d;&quot;taxi&quot; required value&#x3d;&quot;tuktuk&quot;&gt; Tuk Tuk &lt;&#x2f;label&gt;&lt;&#x2f;p&gt;&#xa;&lt;&#x2f;fieldset&gt;&#xa;&#xa;&lt;fieldset&gt;&#xa;&lt;legend&gt;Extras&lt;&#x2f;legend&gt;&#xa;&lt;p&gt;&lt;label class&#x3d;&quot;choice&quot;&gt; &lt;input type&#x3d;&quot;checkbox&quot; name&#x3d;&quot;extras&quot; value&#x3d;&quot;baby&quot;&gt; Baby Seat &lt;&#x2f;label&gt;&lt;&#x2f;p&gt;&#xa;&lt;p&gt;&lt;label class&#x3d;&quot;choice&quot;&gt; &lt;input type&#x3d;&quot;checkbox&quot; name&#x3d;&quot;extras&quot; value&#x3d;&quot;wheelchair&quot;&gt; Wheelchair Access &lt;&#x2f;label&gt;&lt;&#x2f;p&gt;&#xa;&lt;p&gt;&lt;label class&#x3d;&quot;choice&quot;&gt; &lt;input type&#x3d;&quot;checkbox&quot; name&#x3d;&quot;extras&quot; value&#x3d;&quot;tip&quot;&gt; Stock Tip &lt;&#x2f;label&gt;&lt;&#x2f;p&gt;&#xa;&lt;&#x2f;fieldset&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Pickup Date&#x2f;Time&#xa;&lt;input type&#x3d;&quot;datetime-local&quot; name&#x3d;&quot;pickup_time&quot; required&gt;&#xa;&lt;&#x2f;label&gt;&#xa;&lt;&#x2f;p&gt;&#xa;&#x9;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Pickup Place&#xa;&lt;select id&#x3d;&quot;pickup_place&quot; name&#x3d;&quot;pickup_place&quot;&gt;&#xa;&lt;option value&#x3d;&quot;&quot; selected&#x3d;&quot;selected&quot;&gt;Select One&lt;&#x2f;option&gt;&#xa;&lt;option value&#x3d;&quot;office&quot; &gt;Taxi Office&lt;&#x2f;option&gt;&#xa;&lt;option value&#x3d;&quot;town_hall&quot; &gt;Town Hall&lt;&#x2f;option&gt;&#xa;&lt;option value&#x3d;&quot;telepathy&quot; &gt;We&#x27;ll Guess&#x21;&lt;&#x2f;option&gt;&#xa;&lt;&#x2f;select&gt;&#xa;&lt;&#x2f;label&gt; &#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Dropoff Place&#xa;&lt;input type&#x3d;&quot;text&quot; name&#x3d;&quot;dropoff_place&quot; required list&#x3d;&quot;destinations&quot;&gt;&#xa;&lt;&#x2f;label&gt;&#xa;&#xa;&lt;datalist id&#x3d;&quot;destinations&quot;&gt;&#xa;&lt;option value&#x3d;&quot;Airport&quot;&gt;&#xa;&lt;option value&#x3d;&quot;Beach&quot;&gt;&#xa;&lt;option value&#x3d;&quot;Fred Flinstone&#x27;s House&quot;&gt;&#xa;&lt;&#x2f;datalist&gt;&#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Special Instructions&#xa;&lt;textarea name&#x3d;&quot;comments&quot; maxlength&#x3d;&quot;500&quot;&gt;&lt;&#x2f;textarea&gt;&#xa;&lt;&#x2f;label&gt;&#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;p&gt;&lt;button&gt;Submit Booking&lt;&#x2f;button&gt;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;&#x2f;form&gt;&#xa;&#xa;&lt;&#x2f;body&gt;&#xa;&lt;&#x2f;html&gt;</textarea> <p> <a class="btn btn-default" href="/html/html_editors/scratchpad/?example=/html/codes/html_form_code_left_aligned_labels" target="_blank" title="Full-page editor. Opens this example in the full-page editor."><i class="fa fa-pencil-square-o"></i> View Output</i></a> </p> </div> <script> var exampleCode3 = CodeMirror.fromTextArea(document.getElementById("example3"), { mode: "htmlmixed", tabMode: "indent", styleActiveLine: false, lineNumbers: false, lineWrapping: true, theme: "q-dark" }); </script> <h2>Right-Aligned Labels</h2> <p>This enquiry form has right-aligned labels.</p> <div class="code-only"> <textarea id="example4" autocomplete="off" spellcheck="false">&lt;&#x21;DOCTYPE html&gt;&#xa;&lt;html lang&#x3d;&quot;en&quot;&gt;&#xa;&lt;head&gt;&#xa;&lt;meta charset&#x3d;&quot;utf-8&quot;&gt;&#xa;&lt;meta name&#x3d;&quot;viewport&quot; content&#x3d;&quot;width&#x3d;device-width, initial-scale&#x3d;1&quot;&gt;&#xa;&lt;meta http-equiv&#x3d;&quot;x-ua-compatible&quot; content&#x3d;&quot;ie&#x3d;edge&quot;&gt;&#xa;&lt;title&gt;My Example&lt;&#x2f;title&gt;&#xa;&#xa;&lt;&#x21;-- CSS --&gt;&#xa;&lt;style&gt;&#xa;.myForm &#x7b;&#xa;font-family&#x3a; &quot;Lucida Sans Unicode&quot;, &quot;Lucida Grande&quot;, sans-serif&#x3b;&#xa;font-size&#x3a; 0.8em&#x3b;&#xa;width&#x3a; 30em&#x3b;&#xa;padding&#x3a; 1em&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm &#x2a; &#x7b;&#xa;box-sizing&#x3a; border-box&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm label &#x7b;&#xa;padding&#x3a; 0&#x3b;&#xa;font-weight&#x3a; bold&#x3b;&#xa;text-align&#x3a; right&#x3b;&#xa;display&#x3a; block&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm input,&#xa;.myForm select,&#xa;.myForm textarea &#x7b;&#xa;margin-left&#x3a; 2em&#x3b;&#xa;float&#x3a; right&#x3b;&#xa;width&#x3a; 20em&#x3b;&#xa;border&#x3a; 1px solid &#x23;ccc&#x3b;&#xa;font-family&#x3a; &quot;Lucida Sans Unicode&quot;, &quot;Lucida Grande&quot;, sans-serif&#x3b;&#xa;font-size&#x3a; 0.9em&#x3b;&#xa;padding&#x3a; 0.3em&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm textarea &#x7b;&#xa;height&#x3a; 100px&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm button &#x7b;&#xa;padding&#x3a; 1em&#x3b;&#xa;border-radius&#x3a; 0.5em&#x3b;&#xa;background&#x3a; &#x23;eee&#x3b;&#xa;border&#x3a; none&#x3b;&#xa;font-weight&#x3a; bold&#x3b;&#xa;margin-left&#x3a; 14em&#x3b;&#xa;margin-top&#x3a; 1.8em&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm button&#x3a;hover &#x7b;&#xa;background&#x3a; &#x23;ccc&#x3b;&#xa;cursor&#x3a; pointer&#x3b;&#xa;&#x7d;&#xa;&lt;&#x2f;style&gt;&#xa;&#xa;&lt;&#x2f;head&gt;&#xa;&lt;body&gt;&#xa;&#xa;&lt;form class&#x3d;&quot;myForm&quot; method&#x3d;&quot;get&quot; action&#x3d;&quot;&#x2f;html&#x2f;form_handler.cfm&quot;&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Name &#xa;&lt;input type&#x3d;&quot;text&quot; name&#x3d;&quot;customer_name&quot; required&gt;&#xa;&lt;&#x2f;label&gt; &#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Email &#xa;&lt;input type&#x3d;&quot;email&quot; name&#x3d;&quot;email_address&quot;&gt;&#xa;&lt;&#x2f;label&gt;&#xa;&lt;&#x2f;p&gt;&#xa;&#x9;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Enquiry Regarding &#xa;&lt;select id&#x3d;&quot;pickup_place&quot; name&#x3d;&quot;pickup_place&quot;&gt;&#xa;&lt;option value&#x3d;&quot;&quot; selected&#x3d;&quot;selected&quot;&gt;Select One&lt;&#x2f;option&gt;&#xa;&lt;option value&#x3d;&quot;website&quot; &gt;Our Website&lt;&#x2f;option&gt;&#xa;&lt;option value&#x3d;&quot;membership&quot; &gt;Membership&lt;&#x2f;option&gt;&#xa;&lt;option value&#x3d;&quot;telepathy&quot; &gt;We&#x27;ll Guess&#x21;&lt;&#x2f;option&gt;&#xa;&lt;&#x2f;select&gt;&#xa;&lt;&#x2f;label&gt; &#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Enquiry &#xa;&lt;textarea name&#x3d;&quot;comments&quot; maxlength&#x3d;&quot;500&quot;&gt;&lt;&#x2f;textarea&gt;&#xa;&lt;&#x2f;label&gt;&#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;p&gt;&lt;button&gt;Submit Enquiry&lt;&#x2f;button&gt;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;&#x2f;form&gt;&#xa;&#xa;&lt;&#x2f;body&gt;&#xa;&lt;&#x2f;html&gt;</textarea> <p> <a class="btn btn-default" href="/html/html_editors/scratchpad/?example=/html/codes/html_form_code_right_aligned_labels" target="_blank" title="Full-page editor. Opens this example in the full-page editor."><i class="fa fa-pencil-square-o"></i> View Output</i></a> </p> </div> <script> var exampleCode4 = CodeMirror.fromTextArea(document.getElementById("example4"), { mode: "htmlmixed", tabMode: "indent", styleActiveLine: false, lineNumbers: false, lineWrapping: true, theme: "q-dark" }); </script> <h2>Inline Form</h2> <p>This form has its elements displayed inline.</p> <div class="code-only"> <textarea id="example5" autocomplete="off" spellcheck="false">&lt;&#x21;DOCTYPE html&gt;&#xa;&lt;html lang&#x3d;&quot;en&quot;&gt;&#xa;&lt;head&gt;&#xa;&lt;meta charset&#x3d;&quot;utf-8&quot;&gt;&#xa;&lt;meta name&#x3d;&quot;viewport&quot; content&#x3d;&quot;width&#x3d;device-width, initial-scale&#x3d;1&quot;&gt;&#xa;&lt;meta http-equiv&#x3d;&quot;x-ua-compatible&quot; content&#x3d;&quot;ie&#x3d;edge&quot;&gt;&#xa;&lt;title&gt;My Example&lt;&#x2f;title&gt;&#xa;&#xa;&lt;&#x21;-- CSS --&gt;&#xa;&lt;style&gt;&#xa;.myForm &#x7b;&#xa;font-family&#x3a; &quot;Lucida Sans Unicode&quot;, &quot;Lucida Grande&quot;, sans-serif&#x3b;&#xa;font-size&#x3a; 0.8em&#x3b;&#xa;padding&#x3a; 1em&#x3b;&#xa;border&#x3a; 1px solid &#x23;ccc&#x3b;&#xa;border-radius&#x3a; 3px&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm &#x2a; &#x7b;&#xa;box-sizing&#x3a; border-box&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm label &#x7b;&#xa;padding&#x3a; 0&#x3b;&#xa;font-weight&#x3a; bold&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm input &#x7b;&#xa;border&#x3a; 1px solid &#x23;ccc&#x3b;&#xa;border-radius&#x3a; 3px&#x3b;&#xa;font-family&#x3a; &quot;Lucida Sans Unicode&quot;, &quot;Lucida Grande&quot;, sans-serif&#x3b;&#xa;font-size&#x3a; 0.9em&#x3b;&#xa;padding&#x3a; 0.5em&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm input&#x5b;type&#x3d;&quot;email&quot;&#x5d;,&#xa;.myForm input&#x5b;type&#x3d;&quot;password&quot;&#x5d; &#x7b;&#xa;width&#x3a; 12em&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm button &#x7b;&#xa;padding&#x3a; 0.7em&#x3b;&#xa;border-radius&#x3a; 0.5em&#x3b;&#xa;background&#x3a; &#x23;eee&#x3b;&#xa;border&#x3a; none&#x3b;&#xa;font-weight&#x3a; bold&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm button&#x3a;hover &#x7b;&#xa;background&#x3a; &#x23;ccc&#x3b;&#xa;cursor&#x3a; pointer&#x3b;&#xa;&#x7d;&#xa;&lt;&#x2f;style&gt;&#xa;&#xa;&lt;&#x2f;head&gt;&#xa;&lt;body&gt;&#xa;&#xa;&lt;form class&#x3d;&quot;myForm&quot; method&#x3d;&quot;get&quot; action&#x3d;&quot;&#x2f;html&#x2f;form_handler.cfm&quot;&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;Email &#xa;&lt;input type&#x3d;&quot;email&quot; name&#x3d;&quot;user_email&quot; required&gt;&#xa;&lt;&#x2f;label&gt; &#xa;&#xa;&lt;label&gt;Password &#xa;&lt;input type&#x3d;&quot;password&quot; name&#x3d;&quot;user_pwd&quot; required&gt;&#xa;&lt;&#x2f;label&gt;&#xa;&#xa;&lt;button&gt;Log In&lt;&#x2f;button&gt;&#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;p&gt;&#xa;&lt;label&gt;&#xa;&lt;input type&#x3d;&quot;checkbox&quot;&gt; Remember me&#xa;&lt;&#x2f;label&gt;&#xa;&lt;&#x2f;p&gt;&#xa;&#xa;&lt;&#x2f;form&gt;&#xa;&#xa;&lt;&#x2f;body&gt;&#xa;&lt;&#x2f;html&gt;</textarea> <p> <a class="btn btn-default" href="/html/html_editors/scratchpad/?example=/html/codes/html_form_code_inline" target="_blank" title="Full-page editor. Opens this example in the full-page editor."><i class="fa fa-pencil-square-o"></i> View Output</i></a> </p> </div> <script> var exampleCode5 = CodeMirror.fromTextArea(document.getElementById("example5"), { mode: "htmlmixed", tabMode: "indent", styleActiveLine: false, lineNumbers: false, lineWrapping: true, theme: "q-dark" }); </script> <h2>Accessible Compact Form</h2> <p>This form uses the <code>placeholder</code> attribute instead of the <a href="/html/tags/html_label_tag.cfm"><code>&lt;label&gt;</code></a> tag for the email and password fields. This results in a more compact form because no extra space is required for the labels.</p> <p>However, simply removing the <a href="/html/tags/html_label_tag.cfm"><code>&lt;label&gt;</code></a> tags is not good from an accessibility standpoint. People using screen readers could have problems if there is no <a href="/html/tags/html_label_tag.cfm"><code>&lt;label&gt;</code></a> element.</p> <p>Therefore, we use a little CSS trick to "hide" the label from visual browsers, while still presenting them to screen readers. </p> <div class="code-only"> <textarea id="example6" autocomplete="off" spellcheck="false">&lt;&#x21;DOCTYPE html&gt;&#xa;&lt;html lang&#x3d;&quot;en&quot;&gt;&#xa;&lt;head&gt;&#xa;&lt;meta charset&#x3d;&quot;utf-8&quot;&gt;&#xa;&lt;meta name&#x3d;&quot;viewport&quot; content&#x3d;&quot;width&#x3d;device-width, initial-scale&#x3d;1&quot;&gt;&#xa;&lt;meta http-equiv&#x3d;&quot;x-ua-compatible&quot; content&#x3d;&quot;ie&#x3d;edge&quot;&gt;&#xa;&lt;title&gt;My Example&lt;&#x2f;title&gt;&#xa;&#xa;&lt;&#x21;-- CSS --&gt;&#xa;&lt;style&gt;&#xa;.myForm &#x7b;&#xa;font-family&#x3a; &quot;Lucida Sans Unicode&quot;, &quot;Lucida Grande&quot;, sans-serif&#x3b;&#xa;font-size&#x3a; 0.8em&#x3b;&#xa;padding&#x3a; 1em&#x3b;&#xa;border&#x3a; 1px solid &#x23;ccc&#x3b;&#xa;border-radius&#x3a; 3px&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm &#x2a; &#x7b;&#xa;box-sizing&#x3a; border-box&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm label &#x7b;&#xa;font-size&#x3a; 0.9em&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm .audioOnly &#x7b;&#xa;position&#x3a; absolute&#x3b;&#xa;width&#x3a; 1px&#x3b;&#xa;height&#x3a; 1px&#x3b;&#xa;padding&#x3a; 0&#x3b;&#xa;margin&#x3a; -1px&#x3b;&#xa;overflow&#x3a; hidden&#x3b;&#xa;clip&#x3a; rect&#x28;0, 0, 0, 0&#x29;&#x3b;&#xa;border&#x3a; 0&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm input &#x7b;&#xa;border&#x3a; 1px solid &#x23;ccc&#x3b;&#xa;border-radius&#x3a; 3px&#x3b;&#xa;font-family&#x3a; &quot;Lucida Sans Unicode&quot;, &quot;Lucida Grande&quot;, sans-serif&#x3b;&#xa;font-size&#x3a; 0.9em&#x3b;&#xa;padding&#x3a; 0.5em&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm input&#x5b;type&#x3d;&quot;email&quot;&#x5d;,&#xa;.myForm input&#x5b;type&#x3d;&quot;password&quot;&#x5d; &#x7b;&#xa;width&#x3a; 12em&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm button &#x7b;&#xa;padding&#x3a; 0.7em&#x3b;&#xa;border-radius&#x3a; 0.5em&#x3b;&#xa;background&#x3a; &#x23;eee&#x3b;&#xa;border&#x3a; none&#x3b;&#xa;font-weight&#x3a; bold&#x3b;&#xa;margin-left&#x3a; 1.5em&#x3b;&#xa;&#x7d;&#xa;&#xa;.myForm button&#x3a;hover &#x7b;&#xa;background&#x3a; &#x23;ccc&#x3b;&#xa;cursor&#x3a; pointer&#x3b;&#xa;&#x7d;&#xa;&lt;&#x2f;style&gt;&#xa;&#xa;&lt;&#x2f;head&gt;&#xa;&lt;body&gt;&#xa;&#xa;&lt;form class&#x3d;&quot;myForm&quot; method&#x3d;&quot;get&quot; action&#x3d;&quot;&#x2f;html&#x2f;form_handler.cfm&quot;&gt;&#xa;&#xa;&lt;label class&#x3d;&quot;audioOnly&quot; for&#x3d;&quot;user_email&quot;&gt;Email&lt;&#x2f;label&gt; &#xa;&lt;input type&#x3d;&quot;email&quot; name&#x3d;&quot;user_email&quot; required placeholder&#x3d;&quot;Email&quot;&gt;&#xa;&#xa;&lt;label class&#x3d;&quot;audioOnly&quot; for&#x3d;&quot;user_pwd&quot;&gt;Password&lt;&#x2f;label&gt; &#xa;&lt;input type&#x3d;&quot;password&quot; name&#x3d;&quot;user_pwd&quot; required placeholder&#x3d;&quot;Password&quot;&gt;&#xa;&#xa;&lt;label&gt;&#xa;&lt;input type&#x3d;&quot;checkbox&quot;&gt; Remember me&#xa;&lt;&#x2f;label&gt;&#xa;&#xa;&lt;button&gt;Log In&lt;&#x2f;button&gt;&#xa;&#xa;&lt;&#x2f;form&gt;&#xa;&#xa;&lt;&#x2f;body&gt;&#xa;&lt;&#x2f;html&gt;</textarea> <p> <a class="btn btn-default" href="/html/html_editors/scratchpad/?example=/html/codes/html_form_code_inline_compact_accessible" target="_blank" title="Full-page editor. Opens this example in the full-page editor."><i class="fa fa-pencil-square-o"></i> View Output</i></a> </p> </div> <script> var exampleCode6 = CodeMirror.fromTextArea(document.getElementById("example6"), { mode: "htmlmixed", tabMode: "indent", styleActiveLine: false, lineNumbers: false, lineWrapping: true, theme: "q-dark" }); </script> <h2>Bootstrap Forms</h2> <p><a href="/bootstrap/">Bootstrap</a> includes a bunch of components for dealing with forms. Here are two.</p> <h3>Responsive Grid System</h3> <p>You can combine <a href="/bootstrap/bootstrap_3/tutorial/bootstrap_forms.cfm">Bootstrap forms</a> with <a href="/bootstrap/bootstrap_3/tutorial/bootstrap_grid_system.cfm">Bootstrap grids</a> to allow you more control over the layout of your forms. This is particularly useful for developing responsive forms.</p> <div class="code-only"> <textarea id="example7" autocomplete="off" spellcheck="false">&lt;&#x21;DOCTYPE html&gt;&#xa;&lt;html lang&#x3d;&quot;en&quot;&gt;&#xa;&lt;head&gt;&#xa;&lt;meta charset&#x3d;&quot;utf-8&quot;&gt;&#xa;&lt;meta name&#x3d;&quot;viewport&quot; content&#x3d;&quot;width&#x3d;device-width, initial-scale&#x3d;1&quot;&gt;&#xa;&lt;meta http-equiv&#x3d;&quot;x-ua-compatible&quot; content&#x3d;&quot;ie&#x3d;edge&quot;&gt;&#xa;&lt;title&gt;My Example&lt;&#x2f;title&gt;&#xa;&lt;&#x21;-- Bootstrap CSS --&gt;&#xa;&lt;link rel&#x3d;&quot;stylesheet&quot; href&#x3d;&quot;&#x2f;&#x2f;maxcdn.bootstrapcdn.com&#x2f;bootstrap&#x2f;3.3.5&#x2f;css&#x2f;bootstrap.min.css&quot;&gt;&#xa;&#xa;&lt;&#x2f;head&gt;&#xa;&lt;body&gt;&#xa;&#xa;&lt;&#x21;-- HTML Form --&gt;&#xa;&lt;div class&#x3d;&quot;container-fluid&quot;&gt;&#x9;&#x9;&#xa;&lt;div class&#x3d;&quot;row&quot;&gt;&#xa;&#xa;&lt;div class&#x3d;&quot;col-xs-2&quot;&gt;&#xa;&lt;input type&#x3d;&quot;text&quot; class&#x3d;&quot;form-control&quot; placeholder&#x3d;&quot;Title&quot;&gt;&#xa;&lt;&#x2f;div&gt;&#xa;&#xa;&lt;div class&#x3d;&quot;col-xs-4&quot;&gt;&#xa;&lt;input type&#x3d;&quot;text&quot; class&#x3d;&quot;form-control&quot; placeholder&#x3d;&quot;First Name&quot;&gt;&#xa;&lt;&#x2f;div&gt;&#xa;&#xa;&lt;div class&#x3d;&quot;col-xs-6&quot;&gt;&#xa;&lt;input type&#x3d;&quot;text&quot; class&#x3d;&quot;form-control&quot; placeholder&#x3d;&quot;Last Name&quot;&gt;&#xa;&lt;&#x2f;div&gt;&#xa;&#xa;&lt;&#x2f;div&gt;&#xa;&lt;&#x2f;div&gt;&#xa;&#x9;&#x9;&#xa;&lt;&#x21;-- jQuery library --&gt;&#xa;&lt;script src&#x3d;&quot;&#x2f;&#x2f;ajax.googleapis.com&#x2f;ajax&#x2f;libs&#x2f;jquery&#x2f;1.11.3&#x2f;jquery.min.js&quot;&gt;&lt;&#x2f;script&gt;&#xa;&lt;&#x21;-- Bootstrap JS --&gt;&#xa;&lt;script src&#x3d;&quot;&#x2f;&#x2f;maxcdn.bootstrapcdn.com&#x2f;bootstrap&#x2f;3.3.5&#x2f;js&#x2f;bootstrap.min.js&quot;&gt;&lt;&#x2f;script&gt; &#xa;&lt;&#x2f;body&gt;&#xa;&lt;&#x2f;html&gt;</textarea> <p> <a class="btn btn-default" href="/html/html_editors/scratchpad/?example=/html/codes/html_form_code_with_bootstrap_grid_system" target="_blank" title="Full-page editor. Opens this example in the full-page editor."><i class="fa fa-pencil-square-o"></i> View Output</i></a> </p> </div> <script> var exampleCode7 = CodeMirror.fromTextArea(document.getElementById("example7"), { mode: "htmlmixed", tabMode: "indent", styleActiveLine: false, lineNumbers: false, lineWrapping: true, theme: "q-dark" }); </script> <h3>Validation Styles &amp; Feedback Icons</h3> <p>You can also take advantage of Bootstrap's validation styles and feedback icons so that you can provide visual feedback to the user based on the data they enter.</p> <div class="code-only"> <textarea id="example8" autocomplete="off" spellcheck="false">&lt;&#x21;DOCTYPE html&gt;&#xa;&lt;html lang&#x3d;&quot;en&quot;&gt;&#xa;&lt;head&gt;&#xa;&lt;meta charset&#x3d;&quot;utf-8&quot;&gt;&#xa;&lt;meta name&#x3d;&quot;viewport&quot; content&#x3d;&quot;width&#x3d;device-width, initial-scale&#x3d;1&quot;&gt;&#xa;&lt;meta http-equiv&#x3d;&quot;x-ua-compatible&quot; content&#x3d;&quot;ie&#x3d;edge&quot;&gt;&#xa;&lt;title&gt;My Example&lt;&#x2f;title&gt;&#xa;&lt;&#x21;-- Bootstrap CSS --&gt;&#xa;&lt;link rel&#x3d;&quot;stylesheet&quot; href&#x3d;&quot;&#x2f;&#x2f;maxcdn.bootstrapcdn.com&#x2f;bootstrap&#x2f;3.3.5&#x2f;css&#x2f;bootstrap.min.css&quot;&gt;&#xa;&#xa;&lt;&#x2f;head&gt;&#xa;&lt;body&gt;&#xa;&lt;div class&#x3d;&quot;container-fluid&quot;&gt;&#xa;&#x9;&#x9;&#xa;&lt;div class&#x3d;&quot;form-group has-success has-feedback&quot;&gt;&#xa; &lt;label class&#x3d;&quot;control-label&quot; for&#x3d;&quot;username&quot;&gt;Username&lt;&#x2f;label&gt;&#xa; &lt;input type&#x3d;&quot;text&quot; class&#x3d;&quot;form-control&quot; id&#x3d;&quot;username&quot; aria-describedby&#x3d;&quot;usernameStatus&quot;&gt;&#xa; &lt;span class&#x3d;&quot;glyphicon glyphicon-ok form-control-feedback&quot; aria-hidden&#x3d;&quot;true&quot;&gt;&lt;&#x2f;span&gt;&#xa; &lt;span id&#x3d;&quot;usernameStatus&quot; class&#x3d;&quot;help-block&quot;&gt;Username is available&#x21;&lt;&#x2f;span&gt;&#xa;&lt;&#x2f;div&gt;&#xa;&lt;div class&#x3d;&quot;form-group has-warning has-feedback&quot;&gt;&#xa; &lt;label class&#x3d;&quot;control-label&quot; for&#x3d;&quot;password&quot;&gt;Password&lt;&#x2f;label&gt;&#xa; &lt;input type&#x3d;&quot;password&quot; class&#x3d;&quot;form-control&quot; id&#x3d;&quot;password&quot; aria-describedby&#x3d;&quot;passwordStatus&quot;&gt;&#xa; &lt;span class&#x3d;&quot;glyphicon glyphicon-warning-sign form-control-feedback&quot; aria-hidden&#x3d;&quot;true&quot;&gt;&lt;&#x2f;span&gt;&#xa; &lt;span id&#x3d;&quot;passwordStatus&quot; class&#x3d;&quot;help-block&quot;&gt;Weak password&lt;&#x2f;span&gt;&#xa;&lt;&#x2f;div&gt;&#xa;&lt;div class&#x3d;&quot;form-group has-error has-feedback&quot;&gt;&#xa; &lt;label class&#x3d;&quot;control-label&quot; for&#x3d;&quot;phone&quot;&gt;Phone Number&lt;&#x2f;label&gt;&#xa; &lt;input type&#x3d;&quot;tel&quot; class&#x3d;&quot;form-control&quot; id&#x3d;&quot;phone&quot; aria-describedby&#x3d;&quot;phoneStatus&quot;&gt;&#xa; &lt;span class&#x3d;&quot;glyphicon glyphicon-remove form-control-feedback&quot; aria-hidden&#x3d;&quot;true&quot;&gt;&lt;&#x2f;span&gt;&#xa; &lt;span id&#x3d;&quot;phoneStatus&quot; class&#x3d;&quot;help-block&quot;&gt;Please enter a valid phone number&lt;&#x2f;span&gt;&#xa;&lt;&#x2f;div&gt;&#xa;&#xa;&lt;&#x2f;div&gt;&#xa;&#x9;&#x9;&#xa;&lt;&#x21;-- jQuery library --&gt;&#xa;&lt;script src&#x3d;&quot;&#x2f;&#x2f;ajax.googleapis.com&#x2f;ajax&#x2f;libs&#x2f;jquery&#x2f;1.11.3&#x2f;jquery.min.js&quot;&gt;&lt;&#x2f;script&gt;&#xa;&lt;&#x21;-- Bootstrap JS --&gt;&#xa;&lt;script src&#x3d;&quot;&#x2f;&#x2f;maxcdn.bootstrapcdn.com&#x2f;bootstrap&#x2f;3.3.5&#x2f;js&#x2f;bootstrap.min.js&quot;&gt;&lt;&#x2f;script&gt; &#xa;&lt;&#x2f;body&gt;&#xa;&lt;&#x2f;html&gt;</textarea> <p> <a class="btn btn-default" href="/html/html_editors/scratchpad/?example=/html/codes/html_form_code_with_bootstrap_validation_styles_and_feedback_icons" target="_blank" title="Full-page editor. Opens this example in the full-page editor."><i class="fa fa-pencil-square-o"></i> View Output</i></a> </p> </div> <script> var exampleCode8 = CodeMirror.fromTextArea(document.getElementById("example8"), { mode: "htmlmixed", tabMode: "indent", styleActiveLine: false, lineNumbers: false, lineWrapping: true, theme: "q-dark" }); </script> <h2>Form-Associated Elements</h2> <p>HTML forms are created using the <a href="/html/tags/html_form_tag.cfm"><code>&lt;form&gt;</code></a> element along with one or more form-associated elements (i.e. elements that can have a form-owner).</p> <p>Here are the form-associated elements.</p> <ul class="col-3"> <li><a href="/html/tags/html_button_tag.cfm"><code>&lt;button&gt;</code></a></li> <li><a href="/html/tags/html_fieldset_tag.cfm"><code>&lt;fieldset&gt;</code></a></li> <li><a href="/html/tags/html_input_tag.cfm"><code>&lt;input&gt;</code></a></li> <li><a href="/html/tags/html_label_tag.cfm"><code>&lt;label&gt;</code></a></li> <li><a href="/html/tags/html_object_tag.cfm"><code>&lt;object&gt;</code></a></li> <li><a href="/html/tags/html_output_tag.cfm"><code>&lt;output&gt;</code></a></li> <li><a href="/html/tags/html_select_tag.cfm"><code>&lt;select&gt;</code></a></li> <li><a href="/html/tags/html_textarea_tag.cfm"><code>&lt;textarea&gt;</code></a></li> <li><a href="/html/tags/html_img_tag.cfm"><code>&lt;img&gt;</code></a></li> </ul> <h2>The <a href="/html/tags/html_input_tag.cfm"><code>&lt;input&gt;</code></a> Types</h2> <p>HTML5 introduced a large number of "types" that can be used with the <a href="/html/tags/html_input_tag.cfm"><code>&lt;input&gt;</code></a> element (i.e. the values that can be used with the <code>type</code> attribute). This allows you to specify exactly what the field is for, and browsers will perform some (light) validation to prevent users from entering the wrong type of data into an <a href="/html/tags/html_input_tag.cfm"><code>&lt;input&gt;</code></a> field.</p> <p>Here's a complete list of the input types available in HTML5. </p> <table class="tabular"> <tr> <th>Value</th><th>Data Type</th><th>Control Type</th> </tr> <tr> <td><code>hidden</code></td><td>An arbitrary string</td><td>N/A</td> </tr> <tr> <td><code>text</code></td><td>Text with no line breaks</td><td>Text field</td> </tr> <tr> <td><code>search</code></td><td>Text with no line breaks</td><td>Text field</td> </tr> <tr> <td><code>tel</code></td><td>Text with no line breaks</td><td>Text field</td> </tr> <tr> <td><code>url</code></td><td>An absolute URL</td><td>Text field</td> </tr> <tr> <td><code>email</code></td><td>An email address or list of email addresses</td><td>Text field</td> </tr> <tr> <td><code>password</code></td><td>Text with no line breaks (sensitive information)</td><td>Text field that obscures data entry (eg, hides the password by using asterisks (******) or similar)</td> </tr> <tr> <td><code>datetime</code></td><td>A date and time (year, month, day, hour, minute, second, fraction of a second) with the time zone set to UTC</td><td>Date and time control</td> </tr> <tr> <td><code>date</code></td><td>A date (year, month, day) with no time zone</td><td>Date control</td> </tr> <tr> <td><code>month</code></td><td>A date consisting of a year and a month with no time zone</td><td>A month control</td> </tr> <tr> <td><code>week</code></td><td>A date consisting of a week-year number and a week number with no time zone</td><td>A week control</td> </tr> <tr> <td><code>time</code></td><td>A time (hour, minute, seconds, fractional seconds) with no time zone</td><td>A time control</td> </tr> <tr> <td><code>datetime-local</code></td><td>A date and time (year, month, day, hour, minute, second, fraction of a second) with no time zone</td><td>Date and time control</td> </tr> <tr> <td><code>number</code></td><td>A numerical value</td><td>Text field or spinner control</td> </tr> <tr> <td><code>range</code></td><td>A numerical value, with the extra semantic that the exact value is not important</td><td>Slider control or similar</td> </tr> <tr> <td><code>color</code></td><td>An sRGB color with 8-bit red, green, and blue components</td><td>A color well. Enables the user to select a color.</td> </tr> <tr> <td><code>checkbox</code></td><td>A set of zero or more values from a predefined list</td><td>Checkbox</td> </tr> <tr> <td><code>radio</code></td><td>An enumerated value</td><td>Radio button</td> </tr> <tr> <td><code>file</code></td><td>Zero or more files each with a MIME type and optionally a file name</td><td>A label and a button</td> </tr> <tr> <td><code>submit</code></td><td>An enumerated value, with the extra semantic that it must be the last value selected and initiates form submission</td><td>Button</td> </tr> <tr> <td><code>image</code></td><td>A coordinate, relative to a particular image's size, with the extra semantic that it must be the last value selected and initiates form submission</td><td>Either a clickable image, or a button</td> </tr> <tr> <td><code>reset</code></td><td>N/A</td><td>Button</td> </tr> <tr> <td><code>button</code></td><td>N/A</td><td>Button</td> </tr> </table> </article> <div class="sidebar"> <div class="relatedLinks"> <h4>Related</h4> <ul> <li><a href="/html/codes/html_form_to_email.cfm" title="Form that sends an email.">HTML Form To Email</a></li> <li><a href="/html/tutorial/html_forms.cfm" title="From the HTML tutorial.">HTML Forms Tutorial</a></li> <li><a href="/html/codes/add_comments_to_website.cfm" title="">Add Comments to Website</a></li> <li><a href="/html/tags/html_form_tag.cfm" title="">HTML <code>&lt;form&gt;</code> Tag</a></li> </ul> </div> <nav> <ul> <li> <h3><a href="/html/codes/">HTML Codes</a></h3> <ul> <li><a href="/html/codes/html_background_codes.cfm" title="Set background properties on any HTML element.">HTML Background Code</a></li> <li><a href="/html/codes/bold/" title="Specify bold text in your HTML code.">HTML Bold</a></li> <li><a href="/html/codes/color/" title="Add color to your HTML code.">HTML Color</a></li> <li><a href="/html/html_color_codes.cfm" title="Hexadecimal color codes">HTML Color Codes</a></li> <li><a href="/html/codes/comment_box_code.cfm" title="Create a comment box within your HTML codes.">HTML Comment Box Code</a></li> <li><a href="/html/codes/html_scroll_box.cfm" title="Create a scroll box within your HTML codes.">HTML Scrollbox Code</a></li> <li><a href="/html/codes/tables/" title="Add an HTML table to your web page or blog.">HTML Tables</a></li> <li><a href="/html/codes/text/" title="Specify font family, size, color and more within your HTML code.">HTML Text Code</a></li> <li><a href="/html/codes/html_picture_codes.cfm" title="Embed pictures within your HTML code.">HTML Image Code</a></li> <li><a href="/html/codes/link/" title="Create hyperlinks between web pages and other documents.">HTML Link Code</a></li> <li><a href="/html/codes/html_marquee_code.cfm">HTML Marquee Code</a></li> <li><a href="/html/html_music_code.cfm">HTML Music Code</a></li> <li><a href="/html/codes/html_video_codes.cfm">HTML Video Code</a></li> <li><a href="/html/codes/html_form_code.cfm">HTML Form Code</a></li> <li><a href="/html/codes/html_frames_code.cfm">HTML Frames Code</a></li> <li><a href="/html/html_special_characters.cfm" title="ISO-8859-1">HTML Entities</a></li> <li><a href="/html/examples/" title="Copy/paste examples">HTML Examples</a></li> <li><a href="/html/html_help.cfm" title="HTML help with tables, forms, fonts, color, image maps, hyperlinks and more.">HTML Help/Cheat Sheet</a></li> <li><a href="/html/templates/" title="Thousands of pre-built websites">HTML Templates</a></li> <li><a style="padding-left:60px;font-style:italic;" href="/html/codes/">More Codes...</a></li> </ul> </li> <li> <h3><a href="/html/">HTML Reference</a></h3> <ul> <li><a href="/html/tags/" title="Alphabetical list of all HTML tags">HTML Tags</a></li> <li><a href="/html/codes/" title="">HTML Codes</a></li> <li><a href="/html/templates/" title="">HTML Templates</a></li> <li><a href="/html/html_editors/">HTML Editors</a></li> <li><a href="/html/tutorial/" title="">HTML Tutorial</a></li> <li><a href="/create-a-website/" title="">Create a Website</a></li> <li><a href="/character_sets/">Character Set Reference</a></li> </ul> </li> </ul> </nav> <div class="ad ad-left"> <!-- GAM 71161633/QCKIT_quackit/article_vrec_2 --> <div data-fuse="23059511712"></div> </div> </div> <div class="ads"> <div class="ad ad-right"> <!-- GAM 71161633/QCKIT_quackit/article_vrec_1 --> <div data-fuse="23059883626"></div> </div> </div> </div> <div class="searchbox-bottom"> <form action="/search/" id="cse-search-box-bottom" class="site-search"> <div> <input type="hidden" name="cx" value="partner-pub-6331358926293806:npmuvy-i8kk"> <input type="hidden" name="cof" value="FORID:10"> <input type="hidden" name="ie" value="ISO-8859-1"> <input type="text" name="q" size="30" class="site-search-input"> <button type="submit" name="sa" class="site-search-button"><i class="fa fa-search"></i></button> </div> </form> <script src="//cse.google.com/cse/brand?form=cse-search-box-bottom&amp;lang=en"></script> </div> <footer> <p class="about"><a href="/"><i class="fa fa-home"></i> Home</a> | <a href="/about.cfm" rel="nofollow">About</a> | <a href="/contact.cfm" rel="nofollow">Contact</a> | <a href="/terms_of_use.cfm" rel="nofollow">Terms&nbsp;of&nbsp;Use</a> | <a href="/privacy_policy.cfm" rel="nofollow">Privacy&nbsp;Policy</a></p> <p>&#169; Copyright 2000 - 2025 Quackit.com &nbsp;</p> </footer> <script src="/common/js/spectrum/spectrum.js"></script> <script src="/common/js/lightbox2-master/dist/js/lightbox.min.js" charset="utf-8"></script> <script> $(document).ready(function(){ $( "#site-nav-toggler" ).click(function() { $( "#site-nav" ).toggle( "slow" ); }); }); </script> <script> $(function(){var a=window.location.href;$(".sidebar nav a").each(function(){a==this.href&&$(this).closest("li").addClass("selected")})}); </script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10