aboutsummaryrefslogtreecommitdiff
path: root/build/default-brower-forms
diff options
context:
space:
mode:
authorbt <bt@btxx.org>2024-06-08 13:22:19 -0400
committerbt <bt@btxx.org>2024-06-08 13:22:19 -0400
commitdcfb172704f3afb68a30425029ec834be2883274 (patch)
tree02ac480745db802d7af03f3213a0c568322170e3 /build/default-brower-forms
parente146f8a64c793c337999ce316b16ebe5fe6f2dab (diff)
More content porting, on-going markdown changes for lowdown support
Diffstat (limited to 'build/default-brower-forms')
-rw-r--r--build/default-brower-forms/index.html162
1 files changed, 92 insertions, 70 deletions
diff --git a/build/default-brower-forms/index.html b/build/default-brower-forms/index.html
index 48c8dfd..b62ab64 100644
--- a/build/default-brower-forms/index.html
+++ b/build/default-brower-forms/index.html
@@ -1,87 +1,102 @@
<!doctype html>
-<html lang="en" id="top">
+<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="data:,">
<title>Very Basic Form Styling</title>
- <link href="https://bt.ht/atom.xml" type="application/atom+xml" rel="alternate" title="Atom feed for blog posts" />
- <style>*{box-sizing:border-box;}body{font-family:sans-serif;margin:0 auto;max-width:650px;padding:1rem;}img{max-width:100%;}pre{overflow:auto;}table{text-align:left;width:100%;}</style>
+ <link href="/atom.xml" type="application/atom+xml" rel="alternate" title="Atom feed for blog posts" />
+ <link href="/rss.xml" type="application/rss+xml" rel="alternate" title="RSS feed for blog posts" />
+<style>*{box-sizing:border-box;}body{font-family:sans-serif;line-height:1.33;margin:0 auto;max-width:650px;padding:1rem;}img{max-width:100%;}pre{border:1px solid;overflow:auto;padding:5px;}table{text-align:left;width:100%;}.footnotes{font-size:90%;}</style>
</head>
<nav>
- <a href="#menu">Menu &darr;</a>
+ <a href="#menu">Menu &darr;</a>
</nav>
<main>
-<h1>Very Basic Form Styling</h1>
+<h1 id="very-basic-form-styling">Very Basic Form Styling</h1>
+
<p>2019-11-13</p>
-<p>Web forms can be great - I'm borderline obsessed with them. I love tinkering with pre-existing logins / sign up pages and I've also open sourced a minimal CSS form-styling plugin: <a href="https://normform.netlify.com/">Normform</a>. While simple CSS plugins like these can be helpful, I often feel like we are over-engineering our web forms. I'm certainly guilty of it.</p>
-<p>That's not to say developers should just use default browser styling for their forms and call it a day - that is far from ideal. Just pull-back on adding so much styling garbage to the forms themselves.</p>
-<p>Let's check out an embedded demo below to see what some bare-bones form styling could look like:</p>
+
+<p>Web forms can be great - I&#8217;m borderline obsessed with them. I love tinkering with pre-existing logins &#47; sign up pages and I&#8217;ve also open sourced a minimal CSS form-styling plugin: <a href="https://normform.netlify.com/">Normform</a>. While simple CSS plugins like these can be helpful, I often feel like we are over-engineering our web forms. I&#8217;m certainly guilty of it.</p>
+
+<p>That&#8217;s not to say developers should just use default browser styling for their forms and call it a day - that is far from ideal. Just pull-back on adding so much styling garbage to the forms themselves.</p>
+
+<p>Let&#8217;s check out an embedded demo below to see what some bare-bones form styling could look like:</p>
+
<p><a href="https://codepen.io/bradleytaunt/pen/oNwzvMa">Live CodePen Example</a></p>
-<p>This form isn't going to win any design awards or blow anyone away with its creativity. That's okay - because it gets the job done. Users understand it's a form and items are broken down into digestible chunks. Mission accomplished, right?</p>
-<h2>Breaking the form down</h2>
-<p>Let's take a look at the HTML of the entire form:</p>
-<pre><code>&lt;form action=&quot;&quot;&gt;
- &lt;fieldset&gt;
- &lt;legend&gt;Personal Details&lt;/legend&gt;
- &lt;label for=&quot;username&quot;&gt;Desired Username:&lt;/label&gt;
- &lt;input type=&quot;text&quot; id=&quot;username&quot;&gt;
- &lt;label for=&quot;name&quot;&gt;Full Name:&lt;/label&gt;
- &lt;input type=&quot;text&quot; id=&quot;name&quot;&gt;
- &lt;label for=&quot;email&quot;&gt;Email Address:&lt;/label&gt;
- &lt;input type=&quot;email&quot; id=&quot;email&quot;&gt;
- &lt;label for=&quot;date&quot;&gt;Date of Birth:&lt;/label&gt;
- &lt;input type=&quot;date&quot; id=&quot;date&quot;&gt;
- &lt;/fieldset&gt;
- &lt;br&gt;
- &lt;fieldset&gt;
- &lt;legend&gt;Contact Details&lt;/legend&gt;
- &lt;label for=&quot;address&quot;&gt;Home Address:&lt;/label&gt;
- &lt;input type=&quot;text&quot; id=&quot;address&quot;&gt;
- &lt;label for=&quot;postal&quot;&gt;Postal Code:&lt;/label&gt;
- &lt;input type=&quot;text&quot; id=&quot;postal&quot;&gt;
- &lt;label for=&quot;phone&quot;&gt;Phone Number:&lt;/label&gt;
- &lt;input type=&quot;tel&quot; id=&quot;phone&quot;&gt;
- &lt;/fieldset&gt;
- &lt;br&gt;
- &lt;fieldset&gt;
- &lt;legend&gt;Select an Option&lt;/legend&gt;
- &lt;label for=&quot;radio-1&quot;&gt;
- &lt;input type=&quot;radio&quot; id=&quot;radio-1&quot; name=&quot;radio-choice&quot;&gt;
+
+<p>This form isn&#8217;t going to win any design awards or blow anyone away with its creativity. That&#8217;s okay - because it gets the job done. Users understand it&#8217;s a form and items are broken down into digestible chunks. Mission accomplished, right?</p>
+
+<h2 id="breaking-the-form-down">Breaking the form down</h2>
+
+<p>Let&#8217;s take a look at the HTML of the entire form:</p>
+
+<pre><code>&#60;form action=""&#62;
+ &#60;fieldset&#62;
+ &#60;legend&#62;Personal Details&#60;&#47;legend&#62;
+ &#60;label for="username"&#62;Desired Username:&#60;&#47;label&#62;
+ &#60;input type="text" id="username"&#62;
+ &#60;label for="name"&#62;Full Name:&#60;&#47;label&#62;
+ &#60;input type="text" id="name"&#62;
+ &#60;label for="email"&#62;Email Address:&#60;&#47;label&#62;
+ &#60;input type="email" id="email"&#62;
+ &#60;label for="date"&#62;Date of Birth:&#60;&#47;label&#62;
+ &#60;input type="date" id="date"&#62;
+ &#60;&#47;fieldset&#62;
+ &#60;br&#62;
+ &#60;fieldset&#62;
+ &#60;legend&#62;Contact Details&#60;&#47;legend&#62;
+ &#60;label for="address"&#62;Home Address:&#60;&#47;label&#62;
+ &#60;input type="text" id="address"&#62;
+ &#60;label for="postal"&#62;Postal Code:&#60;&#47;label&#62;
+ &#60;input type="text" id="postal"&#62;
+ &#60;label for="phone"&#62;Phone Number:&#60;&#47;label&#62;
+ &#60;input type="tel" id="phone"&#62;
+ &#60;&#47;fieldset&#62;
+ &#60;br&#62;
+ &#60;fieldset&#62;
+ &#60;legend&#62;Select an Option&#60;&#47;legend&#62;
+ &#60;label for="radio-1"&#62;
+ &#60;input type="radio" id="radio-1" name="radio-choice"&#62;
The option is pretty nice
- &lt;/label&gt;
- &lt;label for=&quot;radio-2&quot;&gt;
- &lt;input type=&quot;radio&quot; id=&quot;radio-2&quot; name=&quot;radio-choice&quot;&gt;
+ &#60;&#47;label&#62;
+ &#60;label for="radio-2"&#62;
+ &#60;input type="radio" id="radio-2" name="radio-choice"&#62;
This option is a little bit better
- &lt;/label&gt;
- &lt;label for=&quot;radio-3&quot;&gt;
- &lt;input type=&quot;radio&quot; id=&quot;radio-3&quot; name=&quot;radio-choice&quot;&gt;
+ &#60;&#47;label&#62;
+ &#60;label for="radio-3"&#62;
+ &#60;input type="radio" id="radio-3" name="radio-choice"&#62;
This option is the best
- &lt;/label&gt;
- &lt;/fieldset&gt;
- &lt;br&gt;
- &lt;fieldset&gt;
- &lt;legend&gt;Notifications&lt;/legend&gt;
- &lt;label for=&quot;checkbox-1&quot;&gt;
- &lt;input type=&quot;checkbox&quot; id=&quot;checkbox-1&quot;&gt;
+ &#60;&#47;label&#62;
+ &#60;&#47;fieldset&#62;
+ &#60;br&#62;
+ &#60;fieldset&#62;
+ &#60;legend&#62;Notifications&#60;&#47;legend&#62;
+ &#60;label for="checkbox-1"&#62;
+ &#60;input type="checkbox" id="checkbox-1"&#62;
I would like to receive email notifications
- &lt;/label&gt;
- &lt;label for=&quot;checkbox-2&quot;&gt;
- &lt;input type=&quot;checkbox&quot; id=&quot;checkbox-2&quot;&gt;
+ &#60;&#47;label&#62;
+ &#60;label for="checkbox-2"&#62;
+ &#60;input type="checkbox" id="checkbox-2"&#62;
I would like to subscribe to the weekly newsletter
- &lt;/label&gt;
- &lt;/fieldset&gt;
- &lt;br&gt;
- &lt;input type=&quot;reset&quot; value=&quot;Reset&quot;&gt;
- &lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt;
-&lt;/form&gt;
+ &#60;&#47;label&#62;
+ &#60;&#47;fieldset&#62;
+ &#60;br&#62;
+ &#60;input type="reset" value="Reset"&#62;
+ &#60;input type="submit" value="Submit"&#62;
+&#60;&#47;form&#62;
</code></pre>
-<p>Notice the <code>fieldset</code> and <code>legend</code> elements? I bet you don't see or hear about those HTML items very often. By default, <code>fieldset</code> allows sibling or related inputs to be semantically grouped together. The <code>legend</code> elements give the user great visual cues about which items are grouped together, helping to focus on each section individually as they complete the form. Use these grouping elements as much as possible (when it makes sense of course) for a better guided experience for your users. </p>
+
+<p>Notice the <code>fieldset</code> and <code>legend</code> elements? I bet you don&#8217;t see or hear about those HTML items very often. By default, <code>fieldset</code> allows sibling or related inputs to be semantically grouped together. The <code>legend</code> elements give the user great visual cues about which items are grouped together, helping to focus on each section individually as they complete the form. Use these grouping elements as much as possible (when it makes sense of course) for a better guided experience for your users. </p>
+
<p>Avoid making your own custom sections and instead use these existing HTML semantics.</p>
-<h2>Almost no CSS at all</h2>
-<p>Now it's time to style this form with only 6 property declarations:</p>
+
+<h2 id="almost-no-css-at-all">Almost no CSS at all</h2>
+
+<p>Now it&#8217;s time to style this form with only 6 property declarations:</p>
+
<pre><code>form label {
display: block;
}
@@ -91,24 +106,31 @@ form input {
padding: 10px;
width: 100%;
}
-form input[type=&quot;radio&quot;],
-form input[type=&quot;checkbox&quot;],
-form input[type=&quot;reset&quot;],
-form input[type=&quot;submit&quot;] {
+form input[type="radio"],
+form input[type="checkbox"],
+form input[type="reset"],
+form input[type="submit"] {
width: auto;
}
</code></pre>
+
<p>Of course, you can always add minor adjustments (like in my demo example above)</p>
+
<ul>
<li>Legend typeface and sizing</li>
<li>Form and fieldset background colors</li>
<li>Extra margin and padding</li>
-<li>Custom reset / submit buttons</li>
+<li>Custom reset &#47; submit buttons</li>
</ul>
+
<p>But the main point of this post is to showcase how little CSS is needed to implement decent web forms - so any further improvements are up to you, dear reader. </p>
+
<p>Just try not to reinvent the wheel.</p>
-<h2>Final rant - don't ignore the reset</h2>
-<p>A lot of "modern" web forms have moved away from including the reset input on their forms, which I think is fairly short-sighted. Resetting all form fields might be a smaller edge case, but it is certainly a better option than relying on the user to <i>refresh</i> or in some cases, individually deleting each input. Yikes.</p>
+
+<h2 id="final-rant---dont-ignore-the-reset">Final rant - don&#8217;t ignore the reset</h2>
+
+<p>A lot of &#8220;modern&#8221; web forms have moved away from including the reset input on their forms, which I think is fairly short-sighted. Resetting all form fields might be a smaller edge case, but it is certainly a better option than relying on the user to refresh or in some cases, individually deleting each input. Yikes.</p>
+
<p>Happy form building!</p>
<footer role="contentinfo">
<h2>Menu Navigation</h2>