<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Edit HTML Online]]></title><description><![CDATA[Edit HTML Online]]></description><link>https://edithtmlonline.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 28 Nov 2026 21:33:41 GMT</lastBuildDate><atom:link href="https://edithtmlonline.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Help users recover from HTML form errors with a linked summary]]></title><description><![CDATA[Build a linked form error summary, keep inline hints, and test keyboard focus with a runnable HTML and JavaScript example.]]></description><link>https://edithtmlonline.hashnode.dev/help-users-recover-from-html-form-errors-with-a-linked-summary</link><guid isPermaLink="true">https://edithtmlonline.hashnode.dev/help-users-recover-from-html-form-errors-with-a-linked-summary</guid><category><![CDATA[Accessibility]]></category><dc:creator><![CDATA[Edit HTML Online]]></dc:creator><pubDate>Thu, 26 Nov 2026 21:47:12 GMT</pubDate><content:encoded><![CDATA[<p>A long form can seem to do nothing after you press Submit. The error may be above the visible area or several Tab stops away. Keep each message beside its field, add a short list of the errors near the top, and move focus to the list after a failed submission. Let each link take the user straight to the relevant control.</p>
<h2>Start with native field semantics</h2>
<p>Keep the label visible and associate it with the control using matching <code>for</code> and <code>id</code> values. The label gives the field its name. The hint describes what goes in it. You can keep the hint visible and reserve another element for an error.</p>
<pre><code class="language-html">&lt;label for="email"&gt;Email address (required)&lt;/label&gt;
&lt;p id="email-hint"&gt;Use a sample address like learner@example.com.&lt;/p&gt;
&lt;input id="email" type="email" required aria-describedby="email-hint"&gt;
&lt;p id="email-error" hidden&gt;&lt;/p&gt;
</code></pre>
<p>The browser still exposes <code>input.validity.valueMissing</code> and <code>input.validity.typeMismatch</code> when your enhanced form suppresses the browser's own validation pop-ups.</p>
<h2>Build the summary beside the form</h2>
<p>Give the summary a heading and a list. <code>tabindex="-1"</code> means your script can focus the summary after a failed submission. The links inside still follow normal Tab order.</p>
<pre><code class="language-html">&lt;section id="errors" tabindex="-1" aria-labelledby="errors-title" hidden&gt;
  &lt;h2 id="errors-title"&gt;Check the marked fields&lt;/h2&gt;
  &lt;ul&gt;&lt;/ul&gt;
&lt;/section&gt;
&lt;p id="result" role="status"&gt;&lt;/p&gt;
</code></pre>
<p>When a field fails validation, show its message beside the input and add the identical wording to the list. Add <code>aria-invalid="true"</code> and append the error's ID to the hint already in <code>aria-describedby</code>. A user who jumps straight to the input can then encounter both the instructions and the error. After correcting and resubmitting the field, remove the error ID and leave the hint associated.</p>
<h2>Move focus once after submission</h2>
<p>The following runnable practice page has name and email fields. The form suppresses the default submit only after its script sets up the handler. It displays feedback locally using demo values.</p>
<pre><code class="language-html">&lt;!doctype html&gt;
&lt;html lang="en"&gt;
&lt;meta charset="utf-8"&gt;
&lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
&lt;title&gt;Workshop signup practice&lt;/title&gt;
&lt;main&gt;
  &lt;h1&gt;Workshop signup practice&lt;/h1&gt;
  &lt;p&gt;Try the form with demo values. It sends no data.&lt;/p&gt;
  &lt;section id="errors" tabindex="-1" aria-labelledby="errors-title" hidden&gt;
    &lt;h2 id="errors-title"&gt;Check the marked fields&lt;/h2&gt;
    &lt;ul&gt;&lt;/ul&gt;
  &lt;/section&gt;
  &lt;p id="result" role="status"&gt;&lt;/p&gt;
  &lt;noscript&gt;&lt;p&gt;Enable JavaScript to use this practice form.&lt;/p&gt;&lt;/noscript&gt;
  &lt;form&gt;
    &lt;div&gt;
      &lt;label for="name"&gt;Name (required)&lt;/label&gt;
      &lt;input id="name" autocomplete="name" required&gt;
      &lt;p class="error" id="name-error" hidden&gt;&lt;/p&gt;
    &lt;/div&gt;
    &lt;div&gt;
      &lt;label for="email"&gt;Email address (required)&lt;/label&gt;
      &lt;p class="hint" id="email-hint"&gt;Use a sample address like learner@example.com.&lt;/p&gt;
      &lt;input id="email" type="email" autocomplete="email" aria-describedby="email-hint" required&gt;
      &lt;p class="error" id="email-error" hidden&gt;&lt;/p&gt;
    &lt;/div&gt;
    &lt;p&gt;&lt;button type="submit" disabled&gt;Check the form&lt;/button&gt;&lt;/p&gt;
  &lt;/form&gt;
&lt;/main&gt;
&lt;script&gt;
  const form = document.querySelector('form');
  const summary = document.querySelector('#errors');
  const errorLinks = summary.querySelector('ul');
  const result = document.querySelector('#result');
  const inputs = [document.querySelector('#name'), document.querySelector('#email')];
  const hints = new Map(inputs.map(input =&gt; [input, input.getAttribute('aria-describedby')]));

  function getError(input) {
    if (input.validity.valueMissing || !input.value.trim()) {
      return input.id === 'name' ? 'Enter a name.' : 'Enter an email address.';
    }
    return input.validity.typeMismatch ? 'Enter an address like learner@example.com.' : '';
  }

  function renderFieldError(input, message) {
    const error = document.querySelector('#' + input.id + '-error');
    error.textContent = message;
    error.hidden = !message;
    const description = [hints.get(input), message &amp;&amp; error.id].filter(Boolean).join(' ');
    if (description) input.setAttribute('aria-describedby', description);
    else input.removeAttribute('aria-describedby');
    if (message) input.setAttribute('aria-invalid', 'true');
    else input.removeAttribute('aria-invalid');
  }

  form.addEventListener('submit', event =&gt; {
    event.preventDefault();
    result.textContent = '';
    errorLinks.replaceChildren();
    for (const input of inputs) {
      const message = getError(input);
      renderFieldError(input, message);
      if (!message) continue;

      const item = document.createElement('li');
      const link = document.createElement('a');
      link.href = '#' + input.id;
      link.textContent = message;
      link.addEventListener('click', event =&gt; {
        event.preventDefault();
        input.focus();
      });
      item.append(link);
      errorLinks.append(item);
    }

    summary.hidden = !errorLinks.children.length;
    if (summary.hidden) result.textContent = 'All fields passed the practice check.';
    else summary.focus();
  });
  form.noValidate = true;
  form.querySelector('button').disabled = false;
&lt;/script&gt;
&lt;/html&gt;
</code></pre>
<p>After a failed submission, check that focus reaches the summary. Tab to an error link and press Enter. Your cursor should appear in the matching field. Fill in a name, enter <code>abc</code> as the email, and resubmit. Only the email error should remain. Correct it to <code>learner@example.com</code> and resubmit. The summary should disappear, both fields should lose their invalid state, and the form should expose a success message. Try the same sequence at a narrow width and with your usual screen reader. A keyboard check verifies focus movement and can’t tell you exactly what a particular screen reader announces.</p>
<p>For a production form, handle validation on the server as well. Return specific messages, preserve safe field values, and make the error summary usable if JavaScript fails. Server-side validation also handles errors a browser cannot know about, such as whether a workshop is full.</p>
<p>If you need somewhere to experiment with the example, open the <a href="https://edithtmlonline.com/">Edit HTML Online HTML editor</a> and paste the single file into the HTML pane. If preview settings block JavaScript, save it as an HTML file and open it locally.</p>
<p>Further reading includes the <a href="https://www.w3.org/WAI/tutorials/forms/notifications/">W3C form notifications tutorial</a> and the <a href="https://design-system.service.gov.uk/components/error-summary/">GOV.UK Design System’s error summary guidance</a>.</p>
<p>Disclosure. The Edit HTML Online team prepared this tutorial with AI assistance.</p>
]]></content:encoded></item><item><title><![CDATA[Make a CSS toolbar wrap without losing a button]]></title><description><![CDATA[Fix a CSS toolbar that overflows on mobile with flex-wrap and verify the result against a working HTML example.]]></description><link>https://edithtmlonline.hashnode.dev/make-a-css-toolbar-wrap-without-losing-a-button</link><guid isPermaLink="true">https://edithtmlonline.hashnode.dev/make-a-css-toolbar-wrap-without-losing-a-button</guid><category><![CDATA[CSS]]></category><category><![CDATA[css flexbox]]></category><category><![CDATA[HTML]]></category><dc:creator><![CDATA[Edit HTML Online]]></dc:creator><pubDate>Thu, 26 Nov 2026 20:13:06 GMT</pubDate><content:encoded><![CDATA[<p>Three short buttons can fit on a desktop and overflow on a phone. A flex container lays items on a single line by default. If the items cannot shrink, the last button may end up past the edge of the toolbar. This exercise shows you how to reproduce that failure and measure what changes when wrapping is enabled.</p>
<h2>Make a toolbar that overflows</h2>
<p>Open the <a href="https://edithtmlonline.com/#editor">Edit HTML Online editor</a>. Start with a blank example, then paste this markup into the HTML tab.</p>
<pre><code class="language-html">&lt;div class="toolbar" role="group" aria-label="Article filters"&gt;
  &lt;button type="button"&gt;All articles&lt;/button&gt;
  &lt;button type="button"&gt;Browser tutorials&lt;/button&gt;
  &lt;button type="button"&gt;Website performance&lt;/button&gt;
&lt;/div&gt;
</code></pre>
<p>In the CSS tab, add these styles.</p>
<pre><code class="language-css">body { font: 1rem system-ui; margin: 1rem; }
.toolbar { display: flex; gap: .5rem; }
.toolbar button {
  flex: 0 0 auto;
  font: inherit;
  white-space: nowrap;
  padding: .65rem .8rem;
}
</code></pre>
<p>Set the preview to <strong>Mobile</strong> and run the code. In my Chrome test, the preview viewport was 375 px wide. The toolbar itself had 343 px of available space, and its content needed 458 px. The exact measurements depend on the font and browser. To check your own result, compare the toolbar’s <code>clientWidth</code> and <code>scrollWidth</code> in the browser inspector. If the second value is larger, the content overflows the available width.</p>
<h2>Allow items to wrap</h2>
<p>Add <code>flex-wrap: wrap</code> to the toolbar rule.</p>
<pre><code class="language-css">.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
</code></pre>
<p>At the same width, the last button moves to a new row. In the test, the toolbar’s content width dropped to 343 px, matching the available space. The gap now applies between buttons and between rows. Switch back to Desktop and the buttons can sit on one line again, without a breakpoint.</p>
<h2>Test the edge cases</h2>
<p>Try a longer translated label. Flex wrapping moves whole items onto a new row. A single button that is wider than the container can still overflow. Allow its text to wrap by dropping <code>white-space: nowrap</code>, and cap its inline size when the design calls for it. If a label contains an unusually long unbroken word, try <code>overflow-wrap: anywhere</code> and check how it looks. Tab through the buttons to make sure you can see the focus indicator and that the focus order follows the reading order.</p>
<p>This tutorial was prepared with AI assistance and browser-tested for Edit HTML Online, the publication behind the editor used in the example.</p>
]]></content:encoded></item></channel></rss>