Uncategorized

How to Add a Sticky Add to Cart Bar in WooCommerce Without a Plugin

A WooCommerce sticky add to cart bar keeps the price and the buy button permanently in view while shoppers scroll through descriptions, galleries, tabs and reviews. On mobile, where the real add to cart button disappears after two swipes, that single UI element often does more for conversions than a redesign of the whole product page. Most articles on this topic end with the same advice: install a plugin. This tutorial does the opposite. You will build the bar yourself in a child theme with about 60 lines of PHP, a small CSS file and a lightweight JavaScript scroll listener. No extra plugin, no bloated settings panel, no render-blocking assets, and full control over what the bar shows. What you are going to build A fixed bar that slides in only after the original add to cart form scrolls out of view. Product thumbnail, truncated product name, live price and one clear call to action. Variable product support: the price updates when a variation is selected, and the button switches from Choose options to Add to cart. Zero cumulative layout shift, correct behaviour inside the iPhone safe area, and 44px tap targets. Compatibility with both classic themes and block-based (FSE) product templates. Files you will create in your child theme functions.php (add the two snippets below) assets/css/sticky-atc.css assets/js/sticky-atc.js Plugin or custom code: which one should you pick? Plugins such as Sticky Cart for WooCommerce, Simple Sticky Add To Cart or the various builder add-ons are fine if you want a five minute setup. They are not fine if you care about page weight and Core Web Vitals on product pages. Here is an honest comparison. Criteria Custom code (this tutorial) Sticky add to cart plugin Extra front-end weight About 2 KB CSS + 2 KB JS, product pages only Often 20 to 150 KB, sometimes loaded site-wide Control over markup Total, you own every element Limited to the options exposed Layout shift risk None, the bar is server rendered and animated with transform Common, many inject the bar with JS after load Setup time 20 to 30 minutes 5 minutes Maintenance You maintain it, it never breaks on plugin updates Vendor dependent, can break after WooCommerce updates Cost Free Free to around 79 USD per year Rule of thumb: if your store is above 1,000 sessions a day, the custom version pays for itself in Core Web Vitals alone. Before you start An active child theme. Never edit a parent theme, your changes will be wiped on the next update. FTP, SFTP or the file manager of your host. The theme file editor works too, but a backup first is mandatory. A staging copy if the store is live. WooCommerce with jQuery available (WooCommerce still loads it on product pages, and we use it only for variation events). Step 1: Enqueue the CSS and JS on product pages only Add this to the bottom of your child theme functions.php. The conditional check means the assets never touch your home page, your blog or your checkout. /** * Load sticky add to cart assets on single product pages only. */ add_action( ‘wp_enqueue_scripts’, ‘exp_sticky_atc_assets’ ); function exp_sticky_atc_assets() { if ( ! function_exists( ‘is_product’ ) || ! is_product() ) { return; } wp_enqueue_style( ‘exp-sticky-atc’, get_stylesheet_directory_uri() . ‘/assets/css/sticky-atc.css’, array(), ‘1.0.0’ ); wp_enqueue_script( ‘exp-sticky-atc’, get_stylesheet_directory_uri() . ‘/assets/js/sticky-atc.js’, array( ‘jquery’ ), ‘1.0.0’, true ); } Step 2: Output the bar with a hook Many tutorials hook into woocommerce_after_single_product. That hook does not fire on block-based product templates, which more and more stores now use. Hooking wp_footer with an is_product() check works everywhere, classic or FSE, and it keeps the bar at the end of the DOM where a fixed element belongs. /** * Render the sticky add to cart bar in the footer of single product pages. */ add_action( ‘wp_footer’, ‘exp_sticky_atc_bar’, 20 ); function exp_sticky_atc_bar() { if ( ! function_exists( ‘is_product’ ) || ! is_product() ) { return; } global $product; if ( ! is_a( $product, ‘WC_Product’ ) ) { $product = wc_get_product( get_the_ID() ); } // Skip products nobody can buy from the bar. if ( ! $product || ! $product->is_purchasable() || ! $product->is_in_stock() ) { return; } $is_variable = $product->is_type( ‘variable’ ); $add_text = $product->single_add_to_cart_text(); $options_text = __( ‘Choose options’, ‘child-theme’ ); $price_html = $product->get_price_html(); $image = $product->get_image( ‘woocommerce_gallery_thumbnail’, array( ‘loading’ => ‘eager’, ‘width’ => 48, ‘height’ => 48, ‘alt’ => ”, ) ); ?> <div id=”exp-sticky-atc” class=”exp-sticky-atc” aria-hidden=”true” data-add-text=”<?php echo esc_attr( $add_text ); ?>” data-options-text=”<?php echo esc_attr( $options_text ); ?>” data-default-price=”<?php echo esc_attr( $price_html ); ?>”> <div class=”exp-sticky-atc__inner”> <div class=”exp-sticky-atc__media” aria-hidden=”true”> <?php echo $image; // phpcs:ignore WordPress.Security.EscapeOutput ?> </div> <div class=”exp-sticky-atc__info”> <span class=”exp-sticky-atc__title”><?php echo esc_html( $product->get_name() ); ?></span> <span class=”exp-sticky-atc__price”><?php echo wp_kses_post( $price_html ); ?></span> </div> <button type=”button” class=”button exp-sticky-atc__button” data-product-id=”<?php echo esc_attr( $product->get_id() ); ?>” <?php echo $is_variable ? ‘data-needs-options=”1″‘ : ”; ?>> <?php echo esc_html( $is_variable ? $options_text : $add_text ); ?> </button> </div> </div> <?php } Because the bar is printed by PHP, it exists in the HTML the browser receives. That is the first half of the no-layout-shift strategy: nothing is injected after load. Step 3: The CSS (mobile-first, safe area aware) Create assets/css/sticky-atc.css in your child theme and paste the following. :root { –exp-atc-height: 64px; –exp-atc-offset: 0px; /* raise the bar if you have a chat widget */ } /* Reserve the space at CSS parse time so the footer is never hidden and nothing moves after load. */ @media (max-width: 991px) { body.single-product { padding-bottom: calc(var(–exp-atc-height) + env(safe-area-inset-bottom, 0px)); } } .exp-sticky-atc { position: fixed; left: 0; right: 0; bottom: var(–exp-atc-offset); z-index: 9990; background: #fff; border-top: 1px solid #e5e7eb; box-shadow: 0 -2px 14px rgba(0, 0, 0, .08); padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)); transform: translateY(110%); transition: transform .22s ease; will-change: transform; pointer-events: none; contain: layout paint; } .exp-sticky-atc.is-visible { transform: translateY(0); pointer-events: auto; } .exp-sticky-atc__inner { display: flex; align-items: center; gap: 10px; max-width: 1200px; margin: 0 auto; min-height: 48px; } .exp-sticky-atc__media img { display: block; width: 48px; height: 48px; object-fit: cover; border-radius: 6px; } .exp-sticky-atc__info

How to Add a Sticky Add to Cart Bar in WooCommerce Without a Plugin Read More »

How to Design a Newsletter Signup Form That Converts (Placement, Copy, and CSS)

Most articles about newsletter signup form design stop at inspiration galleries. This one goes further: you get the placement data, the field rules, the copy patterns, and the actual markup, CSS and Express.js endpoint you need to ship a form that converts today. The short answer A high converting newsletter signup form follows six rules: One field (email) unless personalisation genuinely drives revenue. Placed where attention already exists: mid-article inline, end of post, and exit intent beat the footer every time. A value headline, not a label. Replace “Subscribe to our newsletter” with what the reader receives. A specific CTA button: “Send me the weekly tips” outperforms “Submit”. Visible states: focus, error, loading and success, all announced to screen readers. Trust microcopy: frequency, format and a one click unsubscribe promise. Step 1: Choose the right placement Placement affects opt-in rate more than colours, borders or illustrations. The same form can convert ten times better simply by moving it. Here is how the common placements compare in practice. Placement Typical opt-in rate Intrusiveness Best for Inline, mid or end of article 1% to 3% Low Blogs, docs, tutorials Exit intent modal (desktop) 2% to 5% High High traffic pages, ecommerce Two step popup (click a link, then form) 3% to 8% of clickers Low Lead magnets, checklists, templates Sticky bar (top or bottom) 0.5% to 1.5% Medium Site wide, always on offer Sidebar widget 0.3% to 1% Low Desktop heavy audiences Footer 0.1% to 0.5% None Baseline coverage, brand sites Dedicated landing page 10% to 25% None Paid traffic, social bio links Treat those numbers as ranges, not promises. They depend on traffic quality, offer strength and industry. What holds true everywhere is the ordering: intent driven placements beat passive ones. The placement stack that works on most sites Always on: a footer form (cheap, zero friction, catches people who go looking). Primary driver: an inline form after the third or fourth section of every article, plus one at the end. Safety net: an exit intent modal on desktop only, capped at once per 30 days per visitor. Campaign specific: a two step popup attached to a lead magnet link. Never stack a sticky bar, a modal and a slide-in on the same page. Competing prompts kill trust and hurt Core Web Vitals through layout shift. Mobile rules No full screen interstitials on entry. Google treats intrusive interstitials as a ranking negative on mobile. Exit intent does not exist on touch devices. Use scroll depth (60% to 70%) or a time delay instead. Keep the input at least 44px tall and set inputmode=”email” so the keyboard shows the @ key. Step 2: Decide how many fields Every extra field costs conversions. The trade-off is data you can use for segmentation. Form Relative conversion When to use it Email only Baseline (best) Default for content newsletters Email + first name Roughly 5% to 10% lower Only if you actually personalise subject lines Email + topic checkboxes Roughly 10% to 20% lower Multi-product sites where relevance lifts engagement Email + company + role 30%+ lower B2B lead gen, never a plain newsletter Better approach: ask for the email first, then collect the rest on the confirmation page or in the welcome email. The subscriber is already committed, so completion rates are high and your form stays a single input. Step 3: Write copy that earns the address Design gets attention. Copy gets the submit. Three blocks matter: headline, button, reassurance. Headline formulas Outcome + cadence: “One practical Node.js tip, every Friday.” Audience + benefit: “For backend developers who ship: performance patterns explained in 3 minutes.” Curiosity + proof: “The bugs we fixed this week, read by 12,480 developers.” Exclusive access: “Release notes and breaking changes before they hit the docs.” Avoid “Sign up for our newsletter” as a headline. It describes the mechanism, not the reward. Button copy Weak Stronger Why Submit Send me the weekly tips First person, restates the value Subscribe Join 12,480 developers Adds social proof at the click point Sign up Get the first issue Immediate, concrete reward Reassurance microcopy Put one short line directly under the button. Keep it factual: “Two emails a month. Unsubscribe in one click.” “We never share your address. See our privacy policy.” “Double opt-in: you will get a confirmation email first.” The word “spam” can backfire, since it plants the idea. Describe the frequency instead. Newsletter Signup Form Template is a useful companion to this. Step 4: Build the form (HTML) Semantic, accessible markup with a honeypot field for bots and explicit state containers for errors and success. <form class=”nl-form” id=”nl-form” action=”/api/subscribe” method=”post” novalidate> <h2 class=”nl-form__title”>One practical Node.js tip, every Friday</h2> <p class=”nl-form__sub”>Two minute read, code first, no fluff. Join 12,480 developers.</p> <div class=”nl-field”> <label class=”nl-label” for=”nl-email”>Email address</label> <input class=”nl-input” id=”nl-email” name=”email” type=”email” inputmode=”email” autocomplete=”email” placeholder=”[email protected]” required aria-describedby=”nl-error nl-note”> <p class=”nl-error” id=”nl-error” hidden>Please enter a valid email address.</p> </div> <!– Honeypot: hidden from humans, filled by bots –> <div class=”nl-hp”> <label for=”nl-company”>Company</label> <input id=”nl-company” name=”company” type=”text” tabindex=”-1″ autocomplete=”off”> </div> <button class=”nl-button” type=”submit”> <span class=”nl-button__label”>Send me the weekly tips</span> <span class=”nl-spinner” aria-hidden=”true”></span> </button> <p class=”nl-note” id=”nl-note”>Four emails a month. Unsubscribe in one click.</p> <p class=”nl-success” role=”status” hidden>Almost done. Check your inbox and confirm your subscription.</p> </form> Accessibility checklist Always ship a real <label>. A placeholder is not a label and disappears on typing. Link the error message with aria-describedby and toggle aria-invalid=”true”. Give the success message role=”status” so screen readers announce it without stealing focus. Keep contrast at 4.5:1 for text and 3:1 for the input border. Do not hide the honeypot with display:none only; use off-screen positioning so it stays plausible to bots but invisible to users. Step 5: Style it (responsive CSS with validation states) This CSS uses custom properties so you can theme the form in one place, switches to a single row layout on wider screens, and respects reduced motion preferences. .nl-form { –nl-bg: #ffffff; –nl-fg: #111827; –nl-muted: #6b7280; –nl-border: #d1d5db; –nl-accent: #2563eb; –nl-error: #dc2626; –nl-success: #047857; –nl-radius: 10px;

How to Design a Newsletter Signup Form That Converts (Placement, Copy, and CSS) Read More »

How to Create a CSS-Only Accordion Without JavaScript (Details and Summary Tags)

A CSS only accordion is one of the easiest performance wins available on a modern site. No JavaScript bundle, no hydration delay, no ARIA wiring to maintain, and keyboard support that works the second the HTML is parsed. The native <details> and <summary> elements do the heavy lifting, and modern CSS now handles the part that used to require scripting: a smooth open and close animation from zero to auto height. This tutorial gives you the full recipe, plus two copy-ready blocks you can paste straight into a page today: an FAQ accordion and a product specs accordion. We also cover the parts most tutorials skip, such as what actually happens in browsers that do not support the newest animation properties, and when the old checkbox hack is still the right call. Quick answer: what is a CSS-only accordion? A CSS only accordion is an expand and collapse UI built with HTML and CSS alone, with no JavaScript event listeners. There are two ways to build one: The native way (recommended): a series of <details> elements, each with a <summary> header. The browser handles open and close state, focus, keyboard, and screen reader semantics. The checkbox or radio hack (legacy): hidden <input> elements paired with <label> headers and the :checked selector. It animates well but it lies to assistive technology, because a checkbox is not a disclosure widget. Unless you have a very specific reason, use <details>. Here is how the two compare. Criteria details / summary Checkbox hack Keyboard support Built in (Tab, Enter, Space) Needs tabindex tricks Screen reader semantics Announced as an expandable group Announced as a checkbox Find in page (Ctrl+F) Opens the matching panel Fails on hidden content One panel open at a time Yes, with the name attribute Yes, with radio inputs Close animation Yes in modern browsers Yes everywhere Markup weight Minimal Extra inputs and labels Step 1: the markup Start with clean, semantic HTML. Each accordion item is one <details> element, the header is the <summary>, and everything after it is the panel. <div class=”accordion”> <details class=”accordion__item” open> <summary class=”accordion__header”>What is included in the free plan?</summary> <div class=”accordion__panel”> <p>Unlimited projects, 2 GB of storage and community support.</p> </div> </details> <details class=”accordion__item”> <summary class=”accordion__header”>Can I cancel at any time?</summary> <div class=”accordion__panel”> <p>Yes. Cancel in one click from your dashboard, no phone call needed.</p> </div> </details> <details class=”accordion__item”> <summary class=”accordion__header”>Do you offer invoices for companies?</summary> <div class=”accordion__panel”> <p>Every payment generates a PDF invoice with your VAT number.</p> </div> </details> </div> Three rules to remember: The <summary> must be the first child of <details>, otherwise the browser generates an implicit one. Wrap the panel content in a single element. That wrapper is what you will pad and animate. Add open to the item you want expanded on load. Opening the first item is good for engagement, but leave all closed if the list is long. Step 2: remove the default marker Browsers draw a small triangle before the summary text. Remove it so you can design your own icon. .accordion__header { list-style: none; /* Chrome, Firefox, Safari 18+ */ } .accordion__header::-webkit-details-marker { display: none; /* older Safari */ } If you like the native triangle and just want it recoloured or resized, keep it and style the ::marker pseudo element instead: .accordion__header::marker { color: #2563eb; font-size: 1.1em; } Step 3: base styles .accordion { –acc-border: #e5e7eb; –acc-accent: #2563eb; –acc-hover: #f8fafc; max-width: 44rem; border: 1px solid var(–acc-border); border-radius: 12px; overflow: hidden; background: #fff; font-family: system-ui, -apple-system, “Segoe UI”, sans-serif; } .accordion__item + .accordion__item { border-top: 1px solid var(–acc-border); } .accordion__header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; font-weight: 600; line-height: 1.4; cursor: pointer; user-select: none; list-style: none; } .accordion__header:hover { background: var(–acc-hover); } .accordion__header:focus-visible { outline: 3px solid var(–acc-accent); outline-offset: -3px; } .accordion__panel { padding: 0 1.25rem 1.25rem; color: #475569; line-height: 1.65; } Note the :focus-visible rule. Never delete the focus ring on a summary, it is the only visual cue a keyboard user gets. Step 4: a custom marker that rotates A chevron built from two borders costs zero extra requests and inherits the text colour. .accordion__header::after { content: “”; flex: none; width: 0.6rem; height: 0.6rem; margin-inline-end: 0.2rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform 220ms ease; } .accordion__item[open] > .accordion__header::after { transform: rotate(-135deg) translateY(-2px); } Prefer a plus and minus sign? Swap the pseudo element content: .accordion__header::after { content: “+”; font-size: 1.4rem; line-height: 1; border: 0; transform: none; } .accordion__item[open] > .accordion__header::after { content: “\2212″; } Step 5: make it an exclusive accordion (one panel at a time) This used to be the number one reason people reached for JavaScript. It is now a single HTML attribute. Give every <details> in the group the same name value and the browser closes the others automatically. <details class=”accordion__item” name=”faq”> … </details> <details class=”accordion__item” name=”faq”> … </details> <details class=”accordion__item” name=”faq”> … </details> Two details worth knowing: Only one item in a named group may carry the open attribute in the source, otherwise the last one wins. Grouped items do not have to be siblings, although keeping them together is far easier to reason about. Leave name off if you want visitors to open several sections side by side, which is usually better for comparison-style content such as product specs. Step 6: animate the open state with pure CSS Animating from height 0 to auto was impossible for years. Three modern features solve it together: interpolate-size: allow-keywords lets the browser interpolate to and from auto. ::details-content targets the hidden content wrapper the browser creates inside <details>. transition-behavior: allow-discrete keeps the content visible while the closing transition plays. :root { interpolate-size: allow-keywords; } .accordion__item::details-content { block-size: 0; overflow: hidden; opacity: 0; transition: block-size 280ms ease, opacity 220ms ease, content-visibility 280ms allow-discrete; } .accordion__item[open]::details-content { block-size: auto; opacity: 1; } @media (prefers-reduced-motion: reduce) { .accordion__item::details-content, .accordion__header::after { transition: none; } } That is the whole animation. No scrollHeight measurement, no requestAnimationFrame, no layout thrashing. What happens in browsers

How to Create a CSS-Only Accordion Without JavaScript (Details and Summary Tags) Read More »

How to Design a Website for a Dentist: Pages, Booking Flow, and Trust Signals

Most dental practice websites look fine and convert badly. They open with a stock photo of a smiling model, bury the phone number three scrolls down, and hide appointment booking behind a contact form that nobody answers until Monday. Good dentist website design is not an art project. It is a booking machine. Someone with a cracked molar at 11pm is not browsing your site for inspiration. They want to know: do you treat this, do you take my insurance, are you nearby, are you any good, and how fast can I get in? This guide breaks down the exact page structure a dental practice needs, the booking flow that removes friction, and the trust elements that actually move visitors into your chair. Layout examples are written mobile-first, because that is where the majority of dental searches happen. Start With the Only Metric That Matters: Booked Appointments Before you pick a template or a color palette, define what a “win” looks like on your site. For a dental practice there are only four conversion events worth tracking: Online appointment booked (highest value, fully self-service) Phone call from a mobile device (still the number one action for urgent care) New patient form started (pre-visit paperwork completed online) Directions tapped (strong intent, usually a walk-in or same-day call) Every page you build should push toward one of those four. If a page does not serve a conversion event, an SEO purpose, or a trust purpose, it should not exist. Rule of thumb: a dental site of 15 well-built pages outperforms a site of 60 thin ones, every single time. The Page Structure a Dental Practice Website Actually Needs Here is the core sitemap. Build these first, then expand. Page Primary job Main call to action Homepage Qualify the visitor in 5 seconds: location, services, availability Book online / Call now Service pages (one per treatment) Rank for treatment searches and answer cost, pain, duration Book a consultation Meet the team / About Turn an anonymous clinic into real humans Book with a specific dentist New patients Explain the first visit step by step, reduce anxiety Complete forms online Insurance & financing Remove the number one objection: cost Verify my coverage Book an appointment Real-time scheduling, zero friction Confirm booking Smile gallery (before/after) Prove clinical quality visually Book a cosmetic consult Reviews & testimonials Third-party validation in one place Book online Contact & location(s) Address, map, parking, hours, emergency line Get directions / Call Emergency dentist page Capture urgent, high-intent searches Call now (tap-to-call) Blog / patient education Capture informational searches, feed internal links Related service page Privacy, accessibility, HIPAA notice Legal compliance and quiet credibility None One Service, One Page Do not stuff implants, veneers, Invisalign, root canals, and pediatric care onto a single “Services” page. Each treatment has different search intent, different objections, and a different price point. Build a dedicated page for every service you genuinely want more of: General and preventive: cleanings, exams, fillings, sealants Restorative: crowns, bridges, dentures, root canal therapy Cosmetic: veneers, teeth whitening, bonding, smile makeovers Implants: single tooth, multiple, full arch Orthodontics: clear aligners, braces Specialty: pediatric dentistry, sedation dentistry, periodontal treatment, wisdom teeth Emergency dental care Add a short parent “Services” hub page that links to all of them. That hub is for navigation and internal linking, not for ranking. The Service Page Template That Converts Use the same skeleton for every treatment page so patients learn the pattern: H1 with treatment + city (example: Dental Implants in Portland) One-sentence summary of what the treatment solves Booking button + phone number immediately below the intro Who it is for (symptoms and situations in a bullet list) How it works, step by step, with an honest timeline Cost range and financing, even if it is a range Pain and recovery, answered plainly Before and after photos from your own patients 2 to 3 reviews specific to that treatment The dentist who performs it, with photo and credentials FAQ block (5 to 8 questions, marked up with FAQ schema) Final booking call to action Homepage Layout: What Goes Above the Fold on Mobile On a phone you have roughly 650 pixels of height before the first scroll. Spend them like this: Position Element Why Sticky top bar Logo + tap-to-call icon + menu Urgent visitors convert in one tap Hero headline Practice type + city + differentiator Confirms they are in the right place Subline Availability signal (“Same-week appointments, evenings available”) Speed is the top decision factor Primary button Book Online (full width, 48px+ tall) Thumb-friendly, unmissable Secondary button Call (tel: link) For patients who prefer voice Trust strip Star rating + review count + “Most insurance accepted” Kills the two biggest objections early Below the fold, in order: service tiles (icon + name, 2 columns on mobile), a real photo of your actual office, the team row, insurance logos, three reviews, a map with hours, and a closing booking block. That is it. A homepage does not need fourteen sections. Replace the stock photo Patients can spot a stock model instantly, and it quietly signals “we cut corners.” One half-day photo shoot of your real team, real operatories, and real reception area outperforms every premium stock library. Use those images everywhere: homepage hero, team page, service pages, Google Business Profile. The Booking Flow: Where Most Dental Sites Lose Patients A “Request an Appointment” form that emails the front desk is not online booking. It is a lead form with an unknown response time, and it leaks patients overnight and on weekends, which is exactly when people search for a dentist. Three Levels of Booking, Ranked Level What it is Patient friction Verdict 1. Request form Name, email, “preferred time” High, no confirmation Backup only 2. Calendar with fixed slots Bookable blocks, manually synced Medium, risk of double booking Acceptable for small practices 3. Real-time PMS integration Live availability from your practice software Low, instant confirmation Target this The Four-Step Flow That Minimizes Drop-Off Reason

How to Design a Website for a Dentist: Pages, Booking Flow, and Trust Signals Read More »

How to Add a Cookie Consent Banner to a Website Without a Plugin (HTML, CSS, JS)

If you search for a cookie consent banner HTML snippet, you mostly find hosted consent platforms that inject 80 to 150 KB of JavaScript, add extra DNS lookups and sometimes break your Largest Contentful Paint. For a lot of sites, that is overkill. A compliant banner is basically three things: some markup, a stored decision, and a script loader that only fires after the user says yes. This tutorial shows how to build exactly that: a self-hosted cookie consent banner in plain HTML, CSS and vanilla JavaScript, around 2 KB, that stores the user choice in localStorage and conditionally loads analytics scripts only after consent. No dependencies, no external requests, full control over the markup and the styling. What a cookie consent banner actually has to do Before writing code, it helps to know which behaviours are non negotiable under the GDPR and the ePrivacy Directive. Most banners fail not because of their design, but because they fire tracking scripts before the click. There is a practical rundown of it online. Requirement What it means in code Prior consent No analytics, ads or social scripts in the initial HTML. They are injected after the accept click. Freely given A reject option with the same visual weight as accept, on the first layer. Specific and informed Named categories plus a link to your cookie or privacy policy. No pre-ticked boxes Optional categories default to false in your state object. Withdrawable A permanent Cookie settings link in the footer that reopens the banner. Provable Store a timestamp and a version with the decision, and optionally log it server side. Strictly necessary cookies, such as a login session or a CSRF token, do not need consent. That is why the banner below never blocks your own essential functionality. What we are building A fixed bottom banner with Accept all, Reject non-essential and an optional Customize step The decision stored in localStorage as JSON, with a version and a timestamp Google Analytics 4 (or any other tag) injected only when analytics is granted A reusable cc:consent DOM event so other scripts can react Zero external requests, zero layout shift, no render-blocking JavaScript Step 1: the HTML markup Put this just before the closing </body> tag. It is a dialog role, hidden by default, so nothing flashes if consent was already given. cookiesaur.com published something useful on the subject. <div id=’cc-banner’ class=’cc-banner’ role=’dialog’ aria-live=’polite’ aria-labelledby=’cc-title’ aria-describedby=’cc-desc’ hidden> <div class=’cc-inner’> <div class=’cc-text’> <h2 id=’cc-title’ class=’cc-title’>We use cookies</h2> <p id=’cc-desc’ class=’cc-desc’> Essential cookies keep this site running. With your consent we also use analytics cookies to measure how pages are used. You can change your mind at any time. <a href=’/privacy-policy/’ class=’cc-link’>Read our privacy policy</a> </p> </div> <div class=’cc-actions’> <button type=’button’ class=’cc-btn cc-btn-ghost’ data-cc=’reject’>Reject non-essential</button> <button type=’button’ class=’cc-btn cc-btn-solid’ data-cc=’accept’>Accept all</button> </div> </div> </div> Two details that matter: The buttons are real <button> elements, not links or divs, so keyboard and screen reader users get them for free. Reject and accept share the same cc-btn base class. Only the fill changes, which keeps the two choices equally prominent. Step 2: the CSS Inline this in the <head> or add it to your main stylesheet. Because the banner is position: fixed, it never pushes content around, so it cannot hurt your Cumulative Layout Shift score. The piece Cookie Banner: Legal Requirement or Best Practice makes a good next read. .cc-banner{position:fixed;inset:auto 0 0 0;z-index:9999;background:#111;color:#f5f5f5; font:16px/1.5 system-ui,-apple-system,Segoe UI,Roboto,sans-serif; box-shadow:0 -2px 16px rgba(0,0,0,.35)} .cc-banner[hidden]{display:none} .cc-inner{max-width:1100px;margin:0 auto;padding:18px 20px;display:flex;gap:20px; align-items:center;flex-wrap:wrap} .cc-title{margin:0 0 4px;font-size:17px;font-weight:700} .cc-desc{margin:0;font-size:14px;color:#d8d8d8} .cc-link{color:#7fd1ff;text-decoration:underline} .cc-actions{display:flex;gap:10px;margin-left:auto;flex-wrap:wrap} .cc-btn{cursor:pointer;border-radius:6px;padding:11px 18px;font-size:14px;font-weight:600; border:1px solid #f5f5f5;background:transparent;color:#f5f5f5} .cc-btn-solid{background:#f5f5f5;color:#111} .cc-btn:focus-visible{outline:3px solid #7fd1ff;outline-offset:2px} @media (max-width:640px){ .cc-inner{padding:16px;gap:14px} .cc-actions{margin-left:0;width:100%} .cc-btn{flex:1 1 auto} } Step 3: the JavaScript with localStorage This is the core of the whole cookie consent banner. The state object is intentionally boring: a version, a timestamp and a categories map. Keeping the version lets you re-ask for consent when you add a new vendor. (function () { var KEY = ‘cc_consent_v1’; var TTL_DAYS = 180; // re-ask after 6 months var GA_ID = ‘G-XXXXXXXXXX’; // replace with your own var banner = document.getElementById(‘cc-banner’); function readConsent() { try { var raw = window.localStorage.getItem(KEY); if (!raw) return null; var data = JSON.parse(raw); if (!data || !data.ts || !data.categories) return null; var ageDays = (Date.now() – data.ts) / 86400000; if (ageDays > TTL_DAYS) return null; return data; } catch (e) { return null; } } function saveConsent(categories) { var data = { v: 1, ts: Date.now(), categories: categories }; try { window.localStorage.setItem(KEY, JSON.stringify(data)); } catch (e) {} return data; } function loadAnalytics() { if (window.__ccAnalytics) return; window.__ccAnalytics = true; var s = document.createElement(‘script’); s.async = true; s.src = ‘https://www.googletagmanager.com/gtag/js?id=’ + GA_ID; document.head.appendChild(s); window.dataLayer = window.dataLayer || []; window.gtag = function () { window.dataLayer.push(arguments); }; window.gtag(‘js’, new Date()); window.gtag(‘config’, GA_ID, { anonymize_ip: true }); } function applyConsent(data) { if (data.categories.analytics) loadAnalytics(); document.dispatchEvent(new CustomEvent(‘cc:consent’, { detail: data })); } function hideBanner() { banner.hidden = true; } function showBanner() { banner.hidden = false; var first = banner.querySelector(‘[data-cc=\”accept\”]’); if (first) first.focus({ preventScroll: true }); } function decide(categories) { applyConsent(saveConsent(categories)); hideBanner(); } banner.addEventListener(‘click’, function (e) { var action = e.target.getAttribute && e.target.getAttribute(‘data-cc’); if (action === ‘accept’) decide({ essential: true, analytics: true }); if (action === ‘reject’) decide({ essential: true, analytics: false }); }); // Footer link: <button type=’button’ data-cc-open>Cookie settings</button> document.addEventListener(‘click’, function (e) { var opener = e.target.closest && e.target.closest(‘[data-cc-open]’); if (opener) { e.preventDefault(); showBanner(); } }); var stored = readConsent(); if (stored) { applyConsent(stored); } else { showBanner(); } })(); Load it with <script src=’/js/cookie-consent.js’ defer></script>. Because it is deferred and dependency free, it costs you nothing on first paint. Why localStorage instead of a cookie? Storage Pros Cons localStorage No bytes sent on every request, easy JSON, simple to inspect and clear Not readable server side, per origin only Cookie Readable in your backend, works across subdomains Adds weight to every HTTP request, needs escaping and expiry handling Use localStorage when all your tags are client side, which is the common case. Switch to a first-party cookie if your server needs to know the decision

How to Add a Cookie Consent Banner to a Website Without a Plugin (HTML, CSS, JS) Read More »

How to Design a Testimonials Section That Builds Trust (Layouts and CSS Examples)

Most testimonial sections fail for the same reason: they look like decoration instead of evidence. A row of anonymous five-star quotes with stock photos gets skimmed and forgotten. A single sentence from a named buyer describing a measurable outcome can carry an entire landing page. This guide is not another gallery of screenshots. It covers the testimonial section design decisions that actually move conversion rates: which layout to use for which page, what makes a quote credible, and the CSS you can paste into your project today. Every snippet below is dependency-free, responsive, and accessible. What is a testimonial section (and what it is really for) A testimonial section is a block on a web page that displays quotes, ratings or short stories from real customers, usually with the person’s name, photo, role and company. Structurally it is a set of <blockquote> elements with attribution. Its job is narrow and specific: to remove a doubt at the exact moment the visitor feels it. That is why placement matters as much as visual design. A testimonial about onboarding speed belongs next to the pricing table, not buried in a carousel at the bottom of the homepage. The credibility checklist: what makes a testimonial believable Before you touch CSS, audit your content. A beautiful section filled with weak quotes converts worse than an ugly section filled with strong ones. Score each testimonial out of 7: Signal Weak version Strong version Full name Sarah M. Sarah Mendel Real photo Stock portrait or initials LinkedIn-style headshot Job title + company Happy customer Head of Engineering, Northline Logistics Specific result Great service, highly recommend Cut our API response time from 800ms to 120ms in three weeks Objection handled Nice team to work with I was worried about migration downtime. We shipped with zero downtime. Verifiable source No link Link to G2 review, LinkedIn profile or case study Length 200+ words of praise 20 to 45 words, one idea Rule of thumb: if a quote could have been written about any company in your industry, it is not a testimonial, it is filler. Delete it. One practical trick: bold the result inside the quote. Readers skim testimonials, so highlighting the number or outcome makes the proof survive a two-second glance. Where to place testimonials: homepage, service page, pricing page Placement is the highest-leverage decision in testimonial section design. Use the doubt each page creates as your map. Page Placement Best layout What the quote must prove Homepage Logo strip directly under the hero, full grid after the second value block Logo strip + 3-card grid Serious companies trust us Service / feature page Inline after each feature explanation Single pull quote (no card) This specific feature delivered a specific result Pricing page Immediately below the plan table, above the FAQ 2 quote cards focused on ROI The price was worth it and there were no surprises Checkout / signup Sidebar next to the form One compact quote + rating Signing up is safe and quick Blog post Mid-article, near the CTA Inline pull quote We practice what we write about Two placement mistakes to avoid: putting the only testimonial section in the footer area where scroll depth drops below 30 percent, and repeating the exact same three quotes on every page so returning visitors stop seeing them. Shared base CSS (paste this first) All layouts below share the same card and attribution styles, so define them once. :root{ –t-bg:#ffffff; –t-border:#e5e7eb; –t-text:#1f2937; –t-muted:#6b7280; –t-accent:#0f766e; –t-radius:14px; } .t-section{padding:72px 20px;max-width:1160px;margin-inline:auto} .t-head{max-width:640px;margin:0 auto 40px;text-align:center} .t-head h2{font-size:clamp(1.5rem,3vw,2.125rem);line-height:1.2;margin:0 0 12px} .t-head p{color:var(–t-muted);margin:0} .t-card{ background:var(–t-bg); border:1px solid var(–t-border); border-radius:var(–t-radius); padding:24px; display:flex; flex-direction:column; gap:18px; box-shadow:0 1px 2px rgba(16,24,40,.06); } .t-card blockquote{margin:0;font-size:1.0625rem;line-height:1.65;color:var(–t-text)} .t-card blockquote strong{color:var(–t-accent)} .t-person{display:flex;align-items:center;gap:12px;margin-top:auto} .t-person img{width:44px;height:44px;border-radius:50%;object-fit:cover;flex:0 0 auto} .t-name{font-weight:600;font-size:.9375rem;line-height:1.3} .t-role{color:var(–t-muted);font-size:.8125rem;line-height:1.3} .t-stars{color:#f59e0b;font-size:.875rem;letter-spacing:2px} And the semantic markup for a single card, reused everywhere: <figure class=’t-card’> <div class=’t-stars’ aria-label=’Rated 5 out of 5′>★★★★★</div> <blockquote>We migrated 14 services in one sprint and <strong>cut hosting costs by 38%</strong>. The rollback plan alone was worth it.</blockquote> <figcaption class=’t-person’> <img src=’/img/sarah-mendel.jpg’ width=’44’ height=’44’ alt=’Sarah Mendel’ loading=’lazy’> <div> <div class=’t-name’>Sarah Mendel</div> <div class=’t-role’>Head of Engineering, Northline Logistics</div> </div> </figcaption> </figure> Use <figure> + <figcaption> rather than a bare <div>. It gives screen readers the relationship between the quote and its author, and it keeps the markup meaningful without extra ARIA. Layout 1: the responsive grid (the safe default) Best for homepages and dedicated testimonial pages. It shows volume of proof at a glance and needs zero JavaScript. .t-grid{ display:grid; gap:24px; grid-template-columns:repeat(auto-fit,minmax(280px,1fr)); align-items:stretch; } /* optional: make the first card the hero quote */ @media (min-width:900px){ .t-grid .t-card:first-child{grid-column:span 2} .t-grid .t-card:first-child blockquote{font-size:1.25rem} } Why auto-fit with minmax: the grid reflows from 3 columns to 2 to 1 without a single media query, and cards never get narrower than a readable 280px. Design decisions that matter here Three or six cards, not four. Four cards create an awkward 2+2 on tablet and a lonely orphan on desktop. Equal height, unequal content. margin-top:auto on the attribution row pins names to the bottom so the grid reads as a tidy baseline. Trim quotes to a similar length. Aim for 25 to 45 words each. Wildly different lengths make the section feel unedited. Layout 2: masonry columns for uneven quote lengths If you have great quotes of very different lengths and refuse to trim them, use CSS columns instead of grid. It looks editorial and avoids huge empty gaps. .t-masonry{columns:3 300px;column-gap:24px} .t-masonry .t-card{break-inside:avoid;margin:0 0 24px} @media (max-width:640px){.t-masonry{columns:1}} Trade-off to know: CSS columns flow content top-to-bottom per column, so the DOM order does not match visual reading order left-to-right. Put your strongest testimonial first anyway, since it will land at the top of column one. Layout 3: scroll-snap slider (no JavaScript) Sliders are right when you have 8+ testimonials and limited vertical space, such as a pricing page or a mobile-first landing page. Build it with native scroll snapping instead of a carousel library. Testimonial Graphic Templates tackles the same question from another angle. .t-slider{ display:flex; gap:20px; overflow-x:auto; scroll-snap-type:x mandatory; scroll-behavior:smooth; padding:4px 4px 20px; -webkit-overflow-scrolling:touch; scrollbar-width:thin;

How to Design a Testimonials Section That Builds Trust (Layouts and CSS Examples) Read More »

How to Add a Custom Loading Animation to a Website With CSS (No JavaScript Library)

Almost every tutorial about a CSS loading animation stops at the same place: here is a spinning circle, copy the keyframes, done. What they rarely tell you is that a badly implemented loading screen can make your site feel slower, push your Largest Contentful Paint later, and create layout shift the moment the content finally appears. This tutorial takes the opposite approach. You will build a lightweight preloader and a skeleton screen with pure CSS, hide them with roughly ten lines of vanilla JavaScript, and apply the rules that keep the animation off the browser’s main thread. No spinner library, no animation framework, no extra kilobytes. This discussion raises a few points we skipped. Quick answer: the minimum viable CSS loading animation If you only need the code, here it is. One element, one keyframe, no dependencies: <div class=”spinner” role=”status” aria-label=”Loading”></div> <style> .spinner { width: 48px; height: 48px; border-radius: 50%; border: 4px solid rgba(0, 0, 0, 0.12); border-top-color: #0b63f6; animation: spinner-rotate 0.8s linear infinite; } @keyframes spinner-rotate { to { transform: rotate(360deg); } } </style> That is the whole spinner. The rest of this article is about the part that actually matters: where you put it, when you remove it, and how to keep it from damaging your performance metrics. First decide: do you even need a loading screen? A full-screen preloader hides your content on purpose. On a fast connection, that means you are deliberately delaying the moment the user sees something useful. Use this table as a decision guide before you write a single line of CSS. Expected wait What to show Why Under 100 ms Nothing The action feels instant. An indicator that flashes for 80 ms only creates visual noise. 100 ms to 1 s Subtle inline state (button spinner, dimmed area) Confirms the click was registered without blocking the page. 1 s to 10 s Skeleton screen or spinner Users need proof that something is happening. Skeletons win for content, spinners for actions. Over 10 s Determinate progress bar with text An infinite spinner for 12 seconds reads as “broken”, not “loading”. Rule of thumb: content pages should almost never use a full-screen preloader. Dashboards, editors, canvas apps and anything that needs to boot before it is usable are the legitimate use cases. Part 1: a full-screen preloader in pure CSS Step 1: the markup Put the overlay as the first element inside the body, before your app markup. It must be able to paint before anything else. <body> <div id=”preloader” class=”preloader” role=”status” aria-live=”polite”> <div class=”preloader__spinner” aria-hidden=”true”></div> <span class=”visually-hidden”>Loading page content</span> </div> <main id=”app”> <!– your real content –> </main> </body> Step 2: inline the critical CSS This is the step most tutorials skip. If your preloader styles live in an external stylesheet that arrives late, the user sees an unstyled flash of your raw HTML first. Put the overlay CSS inline in the <head>, and keep it tiny. <head> <style> .preloader { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; background: #ffffff; opacity: 1; transition: opacity 0.3s ease, visibility 0.3s ease; } .preloader.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; } .preloader__spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid #e3e8ef; border-top-color: #0b63f6; animation: preloader-rotate 0.8s linear infinite; } @keyframes preloader-rotate { to { transform: rotate(360deg); } } .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; } @media (prefers-reduced-motion: reduce) { .preloader__spinner { animation: preloader-fade 1.4s ease-in-out infinite; } @keyframes preloader-fade { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } } } </style> </head> Notice three details: The animation only touches transform, which the browser can composite without repainting. The exit uses opacity plus visibility, not display: none, so the fade actually renders. Users who requested reduced motion get a gentle opacity pulse instead of a rotating element. Step 3: hide it with a few lines of vanilla JavaScript No library needed. Listen for the load event, add a class, then remove the node from the DOM so it never intercepts clicks. (function () { var preloader = document.getElementById(‘preloader’); if (!preloader) return; function hidePreloader() { if (preloader.classList.contains(‘is-hidden’)) return; preloader.classList.add(‘is-hidden’); document.body.classList.remove(‘is-loading’); setTimeout(function () { if (preloader.parentNode) preloader.parentNode.removeChild(preloader); }, 400); } window.addEventListener(‘load’, hidePreloader); // Safety net: never trap the user behind the overlay setTimeout(hidePreloader, 5000); })(); The safety net timeout is not optional. If a third party script hangs, a slow font never resolves, or an image 404s in a way that stalls the load event, your visitors would stare at a spinner forever. Five seconds is a reasonable ceiling. Step 4: handle the no-JavaScript case If JavaScript is blocked or fails to parse, the overlay stays on screen and your site looks dead. Add a pure CSS escape hatch that fades the preloader out on its own: .preloader { animation: preloader-selfdestruct 0s linear 8s forwards; } @keyframes preloader-selfdestruct { to { opacity: 0; visibility: hidden; } } Or, even simpler and stricter: render the overlay itself from a <noscript>-aware class that JavaScript adds to <html> at the very top of the page. If JS never runs, the overlay is never shown. There is more on it in The Progress CSS Loaders Collection. Part 2: the skeleton screen (usually the better choice) A skeleton screen shows the shape of the content before the content exists. Research on perceived performance consistently shows that people rate skeletons as faster than spinners for the same real duration, because the interface looks like it is already assembling itself. Skeleton markup <article class=”card” aria-busy=”true”> <div class=”skeleton skeleton–thumb”></div> <div class=”skeleton skeleton–line” style=”width: 80%”></div> <div class=”skeleton skeleton–line” style=”width: 95%”></div> <div class=”skeleton skeleton–line” style=”width: 60%”></div> </article> Skeleton CSS with a compositor-friendly shimmer .skeleton { position: relative; overflow: hidden; background: #e9edf2; border-radius: 6px; } .skeleton–thumb { aspect-ratio: 16 / 9; margin-bottom: 12px; } .skeleton–line { height: 0.9em; margin-bottom: 8px; } .skeleton::after { content: “”; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient( 90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.65) 50%, rgba(255, 255, 255,

How to Add a Custom Loading Animation to a Website With CSS (No JavaScript Library) Read More »

How to Design a Careers Page That Attracts Better Job Applicants

Most careers pages fail for the same three reasons: they say nothing specific, they bury the open roles, and they hand the applicant a ten-minute form. Good careers page design is not about winning a design award. It is about turning a curious visitor into a qualified applicant in under two minutes, and making sure your roles show up where candidates actually search. This guide breaks down the sections a careers page needs, the copy that goes inside each one, the layout that works on mobile, and the structured data that lets your jobs appear in Google’s job search results. It is written for small business and agency sites, so nothing here needs a six-figure recruitment marketing budget. What a careers page is actually for Before layout, get clear on the job the page has to do. A careers page has four visitors, and each one needs something different: The active applicant who already wants a job with you and just needs the list and the form. The passive candidate who found you through a job listing and is checking whether you are a real, decent company. The referral sent by a friend who works there, looking for the role their friend mentioned. The search engine, which needs machine-readable job data to index and surface your roles. A page that only serves the first visitor becomes a bare list of links. A page that only serves the second becomes a brand film with no jobs on it. You need both, in the right order. The anatomy of a high-converting careers page Section What it does Recommended length 1. Hero States who you are and links straight to open roles Headline + 1 sentence + 1 button 2. Culture blurb Gives candidates a reason to self-select in or out 80 to 150 words 3. Benefits grid Answers “what do I get” at a glance 6 to 9 tiles 4. Open roles list The conversion engine of the page One row per role, no pagination under 25 roles 5. Hiring process Removes anxiety, reduces drop-off before applying 3 to 5 steps with timing 6. Proof Team quotes, photos, review scores 2 to 3 short quotes 7. Application form Captures the applicant with minimum friction 5 to 7 fields 8. Talent pool fallback Catches interest when nothing is open Email + role interest, 2 fields Section 1: The hero The hero is where most careers pages waste their best real estate on a stock photo of people high-fiving. Keep it functional. The point is broken down further in this analysis. Layout Left-aligned text block, image or short muted video on the right (or a full-width photo of your actual team behind a dark overlay). One primary button: View open roles, anchored to the jobs list further down the page. A small counter is useful and honest: “7 open roles across 3 teams”. On mobile, stack text above the image and keep the button above the fold. Copy Write the headline as a statement about the work, not about the company’s ambition. Compare: Weak: “Join our journey to change the world.” Better: “Build software for 400 independent pharmacies, in a team of nine.” Specific numbers do two things: they filter out mismatched applicants and they signal that a real human wrote the page. Section 2: The culture blurb This is the section that separates a careers page from a job board listing. It should be short, concrete, and slightly uncomfortable to write, because it should say something a competitor cannot copy and paste. What to include How you work: meeting load, remote or hybrid policy with actual days, async or synchronous, tooling. How decisions get made: who signs off on what, how much autonomy a new hire really gets. Who thrives here: one sentence describing the person who does well, and one describing who does not. That last point is the highest-value sentence on the whole page. “If you want a structured onboarding programme and a defined career ladder, we are probably too small for you right now” will lose you applicants you did not want and win you trust with the ones you did. Career page design: How to do it right covers this in more depth. Layout tip Break the blurb into two or three short paragraphs of 40 words or fewer, or use a two-column layout with a heading on the left and text on the right. Walls of text in this section get skipped on mobile. Section 3: The benefits grid Candidates scan this. Design for scanning. Layout rules Three columns on desktop, two on tablet, one on mobile. Equal-height cards. Icon or small illustration, a 3 to 5 word label in bold, then one line of detail underneath. Six to nine tiles. Fewer looks thin, more looks like padding. Never use an icon font that fails to load. Inline SVG is safer and faster. Copy rules Quantify everything you can. “Generous holiday” means nothing. “28 days plus public holidays, plus the week between Christmas and New Year” means something. Same for learning budgets, equipment allowances, pension contributions and parental leave. Vague Specific Flexible working Core hours 10:00 to 15:00, the rest is yours Great equipment Laptop of your choice plus a 400 EUR home desk budget Room to grow 1,500 EUR per year for courses and conferences, no approval needed under 300 EUR Competitive salary Published band on every job listing Section 4: The open roles list This is where the page earns its keep. Treat it as a product listing, not a footer link dump. Structure Group by department if you have more than six roles. Otherwise a single flat list is faster to scan. Each row shows: job title, department, location, employment type, and salary band if you publish one. The whole row is clickable, not just the title. Minimum touch target of 44 pixels in height. Filters only if you have 15+ roles. Below that, filters add friction rather than remove it. Every role gets

How to Design a Careers Page That Attracts Better Job Applicants Read More »

How to Create a Mega Menu for a Website With HTML and CSS (No Plugin Needed)

If your site has more than about 25 pages, a single-level dropdown starts to hurt. Links get buried, users scroll inside tiny menus, and your best content never gets clicked. A mega menu fixes that by showing an entire section of your site in one wide panel, organised into columns, with headings, icons and featured links. This tutorial shows how to design a mega menu from the information architecture stage right through to production-ready HTML, CSS and a small JavaScript layer for keyboard and touch users. No page builder, no jQuery, no 200 KB plugin. Everything here works in every modern browser and degrades gracefully. What a Mega Menu Is (and When You Actually Need One) A mega menu is a large, rectangular dropdown panel that opens from a top-level navigation item and displays many links at once, grouped into visible columns and categories. Nielsen Norman Group research has consistently shown that these panels outperform traditional cascading dropdowns because everything is visible in one glance instead of hidden behind hover-and-pray sub-levels. Use a mega menu when: You have 4 or more top-level sections, each with 5 to 20 sub-pages. Your categories benefit from visual grouping (product families, documentation topics, industries, resource types). You want to promote specific pages such as pricing, a free trial, a flagship guide or a new release. Analytics show users going straight to search because the nav does not surface what they need. Skip it when you have fewer than 15 destination pages. A mega menu on a small site is just noise. Mega Menu vs Standard Dropdown Criteria Standard dropdown Mega menu Links visible at once 5 to 10 15 to 40 Grouping and labels Flat list Column headings, icons, descriptions Sub-levels needed Often 2 or 3 deep One level, no cascading Promotion space None Featured card, CTA, image Risk Hidden content Overload if unstructured Step 1: Design the Structure Before You Write Any Code The biggest mistake in mega menu projects is opening a code editor first. Spend 30 minutes on paper or in a spreadsheet instead. Export your page list from your sitemap or CMS. Group pages into 3 to 5 columns per top-level item. Each column gets a short, noun-based heading such as “Hosting”, “Developer tools”, “By industry”. If a column needs more than 8 links, split it or move something to a landing page. Order links by demand, not alphabetically. Put your top traffic and top revenue pages first in each column. Reserve one slot for a featured block per panel: latest release, popular guide, pricing, demo booking. Write link labels as users would search them. “API documentation” beats “Resources for builders”. Cap the panel at roughly 30 links. Beyond that, add a “View all” link to a full section index page. Visual rules that make a mega menu readable Keep panel height under about 480 px so nothing gets cut off on a 13-inch laptop. Use one accent colour for hover states, not five. Icons should be 20 to 24 px, monochrome, and only used when they help identification. Decorative icons on every link slow scanning. Give each link 8 to 12 px vertical padding so touch targets stay usable. Left-align everything. Centered columns are much harder to scan. Add a soft drop shadow and a light top border so the panel reads as a layer above the page. Step 2: The HTML Skeleton Semantic markup does most of the accessibility work for you. Use a <nav>, a real list, and a <button> for anything that opens a panel. Never use a bare <div> or an empty <a href=”#”> as a trigger. <nav class=”mm” aria-label=”Main navigation” data-mega> <a class=”mm-logo” href=”/”>Acme</a> <button class=”mm-burger” aria-expanded=”false” aria-controls=”mm-list”> <span class=”sr-only”>Open menu</span> <span class=”mm-burger-bars” aria-hidden=”true”></span> </button> <ul class=”mm-list” id=”mm-list”> <li class=”mm-item mm-has-panel”> <button class=”mm-trigger” aria-expanded=”false” aria-controls=”panel-products”> Products <span class=”mm-caret” aria-hidden=”true”></span> </button> <div class=”mm-panel” id=”panel-products”> <div class=”mm-grid”> <div class=”mm-col”> <h2 class=”mm-heading”>Hosting</h2> <ul class=”mm-links”> <li><a href=”/shared”> <svg class=”mm-ico” aria-hidden=”true” viewBox=”0 0 24 24″><use href=”#i-server”></use></svg> <span>Shared hosting<span class=”mm-desc”>Best for small sites</span></span> </a></li> <li><a href=”/vps”><span>VPS</span></a></li> <li><a href=”/dedicated”><span>Dedicated servers</span></a></li> </ul> </div> <div class=”mm-col”> <h2 class=”mm-heading”>Developer tools</h2> <ul class=”mm-links”> <li><a href=”/cli”><span>CLI</span></a></li> <li><a href=”/api”><span>REST API</span></a></li> <li><a href=”/webhooks”><span>Webhooks</span></a></li> </ul> </div> <div class=”mm-col”> <h2 class=”mm-heading”>By use case</h2> <ul class=”mm-links”> <li><a href=”/ecommerce”><span>Ecommerce</span></a></li> <li><a href=”/agencies”><span>Agencies</span></a></li> <li><a href=”/saas”><span>SaaS teams</span></a></li> </ul> </div> <div class=”mm-col mm-featured”> <p class=”mm-tag”>New</p> <h2 class=”mm-feat-title”>Edge deploys in 12 seconds</h2> <p class=”mm-desc”>See the benchmark and migration guide.</p> <a class=”mm-btn” href=”/edge”>Read the guide</a> </div> </div> </div> </li> <li class=”mm-item”><a class=”mm-link” href=”/pricing”>Pricing</a></li> <li class=”mm-item”><a class=”mm-link” href=”/contact”>Contact</a></li> </ul> </nav> Notes on the markup: aria-expanded tells screen readers whether the panel is open. JavaScript flips it. aria-controls links the trigger to the panel ID. Column headings use real heading tags so the panel has an outline. If your page heading levels conflict, use <p class=”mm-heading”> plus role=”group” and aria-label on the column instead. Icons carry aria-hidden=”true” because the text already labels the link. Step 3: The CSS That Does the Heavy Lifting The trick for a full-width panel is simple: the parent <nav> is position: relative, the list items stay position: static, and the panel is absolutely positioned with left: 0; right: 0. That stretches the panel edge to edge no matter where the trigger sits. :root{ –mm-ink:#16181d; –mm-muted:#6b7280; –mm-accent:#0b5fff; –mm-line:#e5e7eb; –mm-radius:10px; } .mm{ position:relative; display:flex; align-items:center; gap:24px; padding:0 24px; background:#fff; border-bottom:1px solid var(–mm-line); font-family:system-ui,-apple-system,”Segoe UI”,sans-serif; } .mm-list{display:flex;gap:2px;margin:0;padding:0;list-style:none} .mm-item{position:static} .mm-trigger,.mm-link{ display:flex;align-items:center;gap:7px; padding:20px 14px; background:none;border:0; font:inherit;font-weight:600;font-size:.95rem; color:var(–mm-ink);text-decoration:none;cursor:pointer; } .mm-trigger:hover,.mm-link:hover, .mm-trigger[aria-expanded=”true”]{color:var(–mm-accent)} .mm-caret{ width:7px;height:7px; border-right:2px solid currentColor; border-bottom:2px solid currentColor; transform:rotate(45deg) translateY(-2px); transition:transform .2s ease; } .mm-trigger[aria-expanded=”true”] .mm-caret{transform:rotate(225deg) translateY(2px)} /* The panel */ .mm-panel{ position:absolute;left:0;right:0;top:100%; z-index:60; padding:34px 24px 38px; background:#fff; border-top:1px solid var(–mm-line); box-shadow:0 26px 50px rgba(15,23,42,.12); opacity:0;visibility:hidden; transform:translateY(-10px); transition:opacity .18s ease,transform .18s ease,visibility .18s; } /* Three ways to open: mouse, keyboard, JS class */ .mm-has-panel:hover > .mm-panel, .mm-has-panel:focus-within > .mm-panel, .mm-has-panel.is-open > .mm-panel{ opacity:1;visibility:visible;transform:translateY(0); } /* Columns */ .mm-grid{ display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:34px; max-width:1200px;margin:0 auto; } .mm-heading{ margin:0 0 14px; font-size:.72rem;font-weight:700; letter-spacing:.09em;text-transform:uppercase; color:var(–mm-muted); } .mm-links{margin:0;padding:0;list-style:none} .mm-links li+li{margin-top:4px} .mm-links a{ display:flex;gap:11px;align-items:flex-start; padding:8px 9px;border-radius:var(–mm-radius); color:var(–mm-ink);text-decoration:none;font-size:.93rem; } .mm-links a:hover,.mm-links a:focus-visible{background:#f2f6ff;color:var(–mm-accent)} .mm-ico{flex:0 0 20px;width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.6} .mm-desc{display:block;margin-top:2px;font-size:.8rem;font-weight:400;color:var(–mm-muted)} /* Featured card */ .mm-featured{background:#f7f9fc;border:1px solid var(–mm-line);border-radius:14px;padding:22px} .mm-tag{display:inline-block;margin:0 0

How to Create a Mega Menu for a Website With HTML and CSS (No Plugin Needed) Read More »

How to Add a Video Background to a Website Without Killing Page Speed

A video background website looks great in a design mockup and terrible in a Lighthouse report, at least when it is built the lazy way. Drop a 40 MB MP4 into a hero section, hit publish, and you have just traded 1.5 seconds of Largest Contentful Paint for a bit of motion that most mobile users will never see. It does not have to work that way. This is a practical, performance-first tutorial: the exact HTML5 markup, the encoding commands, the poster image strategy, the mobile fallback, the Express server headers, and the measurements that prove the whole thing did not hurt your Core Web Vitals. We will also cover the part most tutorials skip: when a looping video is the wrong tool and a CSS animation or an animated image is smarter. Dynamic Websites: 5 Excellent Examples of Video Backgrounds covers this in more depth. What a video background website really costs Before writing a line of code, put a number on the decision. A hero video is a bandwidth purchase, and you should know the price. Approach Typical weight (10s loop) Risk to LCP Unoptimised 1080p MP4 straight from the camera or stock site 20 MB to 60 MB Severe Properly encoded H.264 MP4 + WebM, 1280px wide, no audio 700 KB to 2 MB Low if deferred Animated GIF 5 MB to 20 MB Severe (blocking image decode) CSS or SVG animation 2 KB to 30 KB None Rule of thumb: the video file should never be the first thing the browser downloads, and it should never exceed roughly 2 MB for a desktop hero. If your creative concept cannot survive that budget, change the concept, not the budget. Step 1: Decide whether you actually need video Most of the sites you find in a “best video background websites” gallery use footage that carries real meaning: a product in motion, a place, a process, people. If your loop is an abstract gradient, drifting particles, or slow-moving smoke, you are paying megabytes for something a few lines of CSS can fake. If the content is… Use Why Real footage: product, location, people, manufacturing HTML5 <video> loop Only video reproduces real-world detail credibly Abstract motion: gradients, blobs, grain, waves CSS animation, canvas or animated SVG Kilobytes instead of megabytes, resolution independent Short 2 to 3 second UI demo Muted MP4 or animated AVIF/WebP Far smaller than GIF at the same quality Anything on a page whose only job is conversion speed Static image Fastest paint, zero autoplay edge cases And one hard rule: never ship a GIF for a background. A silent MP4 or WebM is roughly ten to twenty times smaller for the same visual result, and the browser can decode it on the GPU. Step 2: Cut and prepare the source clip Editing decisions matter more than encoder settings. Before you touch ffmpeg: Keep it between 6 and 12 seconds. Longer loops rarely get watched and multiply file size linearly. Choose low-motion footage. Slow pans, shallow depth of field and static camera positions compress dramatically better than handheld shots with fast movement or falling confetti. Strip the audio track entirely. A background video must be muted to autoplay anyway, so an audio track is pure waste. Make the loop seamless. Cut on a matching frame, or add a short cross-dissolve between the end and the start so the jump is invisible. Design for the overlay. If text sits over the video, pick footage with a calm area, then darken it with a CSS gradient so contrast ratios stay accessible. Check the licence. Free libraries such as Pexels, Pixabay, Coverr and Mixkit are fine for commercial use, but read the terms for logos, faces and trademarks visible in the frame. Step 3: Encode the video properly Two files cover the whole modern browser landscape: an MP4 (H.264) for universal support and a WebM (VP9 or AV1) that is typically 25 to 50 percent smaller where supported. Recommended output targets Setting Desktop hero Tablet / small viewport Width 1600 to 1920 px 1280 px Frame rate 24 to 25 fps 24 fps Audio None None File size ceiling 2 MB 1 MB Pixel format yuv420p yuv420p ffmpeg commands you can copy H.264 MP4, with the moov atom moved to the front so playback can start before the file finishes downloading: ffmpeg -i source.mov -an \ -vf “scale=1600:-2,fps=25” \ -c:v libx264 -profile:v high -pix_fmt yuv420p \ -crf 27 -preset slow -g 50 \ -movflags +faststart \ hero-1600.mp4 VP9 WebM (broad support, good ratio): ffmpeg -i source.mov -an \ -vf “scale=1600:-2,fps=25” \ -c:v libvpx-vp9 -crf 36 -b:v 0 -row-mt 1 \ hero-1600.webm AV1 WebM if your toolchain has SVT-AV1 (smallest files, slower encode): ffmpeg -i source.mov -an \ -vf “scale=1600:-2,fps=25″ \ -c:v libsvtav1 -crf 40 -preset 6 -pix_fmt yuv420p \ hero-1600-av1.webm Raise the CRF value until you see artefacts, then step back one. Because the video sits behind a dark overlay and moving text, you can usually push CRF several points higher than you would for a video the user is meant to study. Generate the poster image from the first frame ffmpeg -i hero-1600.mp4 -ss 00:00:00.5 -frames:v 1 poster.png cwebp -q 72 poster.png -o hero-poster.webp avifenc –min 24 –max 34 poster.png hero-poster.avif Extracting the poster from the encoded video, not from the raw source, guarantees the still frame and the first video frame match. No flash, no colour shift when playback starts. Step 4: The HTML5 markup Every attribute below is there for a reason. <section class=”hero”> <video class=”hero__video” poster=”/media/hero-poster.avif” muted loop playsinline preload=”none” disablepictureinpicture aria-hidden=”true” tabindex=”-1″> <source data-src=”/media/hero-1600.webm” type=”video/webm”> <source data-src=”/media/hero-1600.mp4″ type=”video/mp4″> </video> <div class=”hero__overlay”></div> <div class=”hero__content”> <h1>Ship your Express app faster</h1> <p>Minimal, unopinionated, production ready.</p> <a class=”btn” href=”/get-started”>Get started</a> </div> </section> What each attribute does muted: mandatory. Chrome, Safari and Firefox all block autoplay with sound. playsinline: prevents iOS from opening the video full screen. Without it, your background becomes a takeover on iPhone. loop: continuous playback, no manual restart logic. preload=”none”: the browser fetches nothing until

How to Add a Video Background to a Website Without Killing Page Speed Read More »

About Us

Express Jam Studio was founded in 2004 by John Smith. John had previously worked for a courier company, but he saw an opportunity to start his own business in the web design and development industry.

Contact Info

Copyright © 2022 Express Jam Studio. All Rights Reserved.