Archive
Every article published on Clean Markup—covering semantic HTML, CSS layout systems, JavaScript algorithms, and web performance.
-
Preventing Layout Shifts with Modern CSS Aspect Ratio Boxes
For years responsive video embeds and fluid card thumbnails required the padding-top percentage wrapper hack. Now browsers compute intrinsic aspect ratios directly from HTML width and height attributes alongside the emerging CSS aspect-ratio property. -
Divide and Conquer Sorting with Merge Sort in JavaScript
While elementary sorting algorithms like Bubble Sort degrade to quadratic O(n^2) time on large datasets, Merge Sort uses a recursive divide-and-conquer strategy to guarantee O(n log n) performance across best, average, and worst-case inputs. -
Optimizing HTML and CSS for Core Web Vitals LCP FID and CLS
Google recently introduced Core Web Vitals as a unified set of real-world user experience metrics focusing on loading speed, interactivity, and visual stability. Here is how clean HTML and CSS directly improve Largest Contentful Paint, First Input Delay, and Cumulative Layout Shift. -
Grouping Media and Code Snippets Semantically with Figure and Figcaption
Many developers only reach for the HTML figure element when embedding photographs, yet the specification defines it for any self-contained unit of content referenced from the main prose including code listings, SVG diagrams, and attributed quotations. -
Canceling Stale Network Requests in JavaScript with AbortController
Asynchronous race conditions frequently happen in typeahead search inputs and tab navigation when an older slow HTTP response resolves after a newer fast request. Using the DOM AbortController API with fetch lets you cancel in-flight requests cleanly. -
Separating Mouse and Keyboard Focus Rings with focus-visible
Setting outline none on buttons and links is one of the most damaging accessibility anti-patterns on the web. The CSS focus-visible pseudo-class lets you display crisp high-contrast focus rings for keyboard Tab users while suppressing persistent rings after mouse or touch clicks. -
Building Performant Sticky Headers and Table of Contents with CSS
Attaching window scroll listeners to toggle a fixed class causes main-thread layout thrashing and visual jumps when elements leave normal document flow. Native CSS position sticky keeps headers and sidebars anchored smoothly on the compositor thread. -
Implementing Binary Search in JavaScript with Logarithmic Complexity
Scanning an unsorted array element by element with indexOf or find takes O(n) linear time. When working with a sorted dataset, Binary Search repeatedly halves the search interval on every comparison to locate any target in O(log n) logarithmic time. -
Designing Inclusive Web Animations with prefers-reduced-motion
Parallax scrolling, zooming cards, and smooth-scroll jumps can trigger dizziness, nausea, and migraines for users with vestibular motion disorders. By using the prefers-reduced-motion CSS media query, you can preserve subtle opacity feedback while stripping out disorienting spatial movement. -
Zero JavaScript Image Deferral with the Native HTML loading Attribute
For years deferring offscreen images required either scroll listeners or IntersectionObserver scripts coupled with data-src attributes. With the native HTML loading attribute now shipping in Chromium and Firefox, browsers can defer below-the-fold images and iframes automatically without a single line of JavaScript.









