<?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[Stormy Studios — Web Notes]]></title><description><![CDATA[Stormy Studios — Web Notes]]></description><link>https://stormystudios.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 12 Nov 2026 08:34:38 GMT</lastBuildDate><atom:link href="https://stormystudios.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[A native HTML FAQ that leaves room for real answers]]></title><description><![CDATA[Build a native HTML and CSS FAQ with clear keyboard focus, flexible answers and reduced-motion support. Includes code, a live demo and testing limits.]]></description><link>https://stormystudios.hashnode.dev/a-native-html-faq-that-leaves-room-for-real-answers</link><guid isPermaLink="true">https://stormystudios.hashnode.dev/a-native-html-faq-that-leaves-room-for-real-answers</guid><category><![CDATA[HTML]]></category><category><![CDATA[CSS]]></category><category><![CDATA[Accessibility]]></category><dc:creator><![CDATA[Stormy Studios]]></dc:creator><pubDate>Tue, 10 Nov 2026 17:18:33 GMT</pubDate><content:encoded><![CDATA[<p>An FAQ should let someone find a question, open it and finish reading the answer. This small <a href="https://codepen.io/editor/Stormy-Studios/pen/01a19d35-61d8-7caa-be59-2a85c9b88e49">working CodePen example</a> uses native HTML disclosures and CSS, with no JavaScript or dependencies. The choices below are useful when adapting it to a small-business website.</p>
<h3>Let HTML manage the disclosure</h3>
<p>Each answer sits inside a <code>details</code> element, with its question in the first <code>summary</code> child. The browser manages opening and closing, so the component needs no custom click handlers or manually synchronised expanded state. That is the disclosure pattern defined by the <a href="https://html.spec.whatwg.org/multipage/interactive-elements.html#the-details-element">HTML Standard</a>.</p>
<p>This excerpt comes from the demo:</p>
<pre><code class="language-html">&lt;details class="faq-item"&gt;
  &lt;summary&gt;
    &lt;span&gt;Does this need JavaScript?&lt;/span&gt;
    &lt;span class="faq-icon" aria-hidden="true"&gt;&lt;/span&gt;
  &lt;/summary&gt;
  &lt;div class="answer"&gt;
    &lt;p&gt;No. The HTML &lt;code&gt;details&lt;/code&gt; and &lt;code&gt;summary&lt;/code&gt; elements provide the disclosure behaviour. CSS handles the layout, focus treatment and small icon change.&lt;/p&gt;
    &lt;p&gt;Use &lt;kbd&gt;Tab&lt;/kbd&gt; to reach a question, then &lt;kbd&gt;Enter&lt;/kbd&gt; or &lt;kbd&gt;Space&lt;/kbd&gt; to open or close it.&lt;/p&gt;
  &lt;/div&gt;
&lt;/details&gt;
</code></pre>
<p>The question text supplies the label. The custom plus/minus icon is decorative, so its span has <code>aria-hidden="true"</code>. The first answer elsewhere in the demo has <code>open</code>, making it visible initially. Remember that <code>open</code> is Boolean: <code>open="false"</code> still opens it; remove the attribute to close it. <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/details">MDN explains these attributes</a>.</p>
<h3>Keep related answers available</h3>
<p>These disclosures deliberately have no shared <code>name</code> attribute. Giving several the same name creates an exclusive group: opening one closes another. Independent answers let a reader compare information without repeatedly reopening it. The trade-off is a longer page when several answers are open; decide according to the content, rather than treating exclusivity as a default.</p>
<p>Essential information, such as opening hours or prices, should also appear where customers need it elsewhere. A collapsed FAQ should not become its only home.</p>
<h3>Make keyboard focus easy to see</h3>
<p>The entire summary is the control, with padding and a minimum height. The demo adds this focus treatment to summaries and links:</p>
<pre><code class="language-css">summary:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
</code></pre>
<p>Here, <code>--focus</code> is defined as <code>#894409</code> against the light surfaces. <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:focus-visible"><code>:focus-visible</code></a> lets the browser decide when focus needs a visible indicator. Check the result after changing colours, and make sure surrounding containers do not clip the outline.</p>
<h3>Give long answers room</h3>
<p>The wrapper uses <code>width: min(100% - 2rem, 46rem)</code>, centred with automatic inline margins. Answers have padding but no fixed height, maximum height or internal scrolling area. Opening one expands normal page flow. Inherited <code>overflow-wrap: anywhere</code> also lets a long unbroken string wrap.</p>
<p>Replace the sample text with realistic content before judging the layout. Try the longest question, several paragraphs and a long link; a short placeholder answer hides problems.</p>
<h3>Respect motion preferences</h3>
<p>Only the decorative icon transitions, for 150 milliseconds. This existing rule removes that transition when the visitor requests reduced motion:</p>
<pre><code class="language-css">@media (prefers-reduced-motion: reduce) {
  .faq-icon::after { transition: none; }
}
</code></pre>
<p>The <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@media/prefers-reduced-motion">media feature</a> reads the device preference. The icon still changes state immediately; the answer itself has no height animation.</p>
<h3>Test beyond the happy path</h3>
<p>Recorded checks confirmed keyboard focus and Enter activation in Chrome, plus a readable final answer in a signed-out browser at a 390px viewport width. Those checks do not establish universal accessibility.</p>
<p>Before reuse, test Space activation, enlarged text, long answers, multiple open items, reduced-motion settings and the actual parent page layout. Fixed-height sections can constrain an otherwise flexible component. Check the browsers and assistive technologies your audience uses: <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/summary#accessibility">MDN notes browser differences in summary semantics</a>. No screen-reader audit or WCAG conformance claim is made for this demo.</p>
<p><em>Prepared with AI assistance using the demo source and linked documentation.</em></p>
<p>Author: <a href="https://stormystudios.com/">Stormy Studios</a>, a web design and development studio in Cornwall.</p>
]]></content:encoded></item></channel></rss>