Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

Back to skills

Cls Dimension Anchor

ASecurity

Prevent layout shift (CLS) by reserving space before anything arrives — width/height attributes and aspect-ratio on images, video, iframes and embeds; min-height on async data regions, feeds, charts, ad slots and dashboards; font metric overrides so web-font swaps don't reflow; scrollbar-gutter; content-visibility with intrinsic size. Use this whenever generating or reviewing HTML/CSS that includes <img>, <picture>, <video>, <iframe>, embeds, lazy-loaded sections, fetched data, charts, third-...

2 stars
0 votes
0 copies
0 views
Added 9/19/2026
designpythonrustgobashperformance

Security Analysis

A100/100

Scanned 9/19/2026

Install to Claude Code

$npx -y skills add fernandokylas/editorial-web-craft --skill cls-dimension-anchor --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cls Dimension Anchor?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Cls Dimension Anchor
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/fernandokylas-cls-dimension-anchor/badge)](https://www.skillsdirectory.com/skills/fernandokylas-cls-dimension-anchor)

More formats (shields.io, HTML) on the badges page.

Download Zip
Files
SKILL.md
---
name: cls-dimension-anchor
description: >-
  Prevent layout shift (CLS) by reserving space before anything arrives — width/height attributes and
  aspect-ratio on images, video, iframes and embeds; min-height on async data regions, feeds, charts,
  ad slots and dashboards; font metric overrides so web-font swaps don't reflow; scrollbar-gutter;
  content-visibility with intrinsic size. Use this whenever generating or reviewing HTML/CSS that
  includes <img>, <picture>, <video>, <iframe>, embeds, lazy-loaded sections, fetched data, charts,
  third-party widgets, web fonts, or cookie/promo banners — and whenever the user says "layout shift",
  "CLS", "the page jumps", "content moves when it loads", "Core Web Vitals", "Lighthouse", or "things
  pop in and push stuff down".
---

# CLS Dimension Anchor

A page that jumps while it loads is a page the user can't trust: the link they were about to tap moves, the paragraph they were reading slides off, the footer lurches down as a chart appears. Every one of those movements has the same cause — something arrived and took space it hadn't been given. The browser lays out what it knows; an image with no dimensions is a 0×0 box until the bytes land, a data region with `height: auto` is nothing until the fetch resolves, a headline in a fallback font is a different width until the web font swaps. Layout shift isn't a performance problem to tune later; it's the absence of a reservation, and reservations are made in markup and CSS before any request goes out.

Treat every non-text module as a box that must have a size *before* its content exists.

## Reserve media with intrinsic dimensions

`<img>` gets `width` and `height` attributes — the browser derives the aspect ratio from them and reserves the box on first layout, before the request starts. Then CSS makes it responsive without breaking the ratio:

```html
<div class="media-aspect-enforcer">
  <img src="remote-asset.jpg" alt="Editorial context description"
       width="800" height="450" class="shielded-image" loading="lazy">
</div>
```
```css
.media-aspect-enforcer { width: 100%; aspect-ratio: 16 / 9; background: var(--rule); overflow: hidden; }
.shielded-image { width: 100%; height: 100%; object-fit: cover; display: block; }
```

Belt and braces on purpose: the attributes reserve the box even before CSS applies; the wrapper's `aspect-ratio` holds the shape when the image is missing, broken, or replaced by a different-ratio source. The soft background is the placeholder colour so an empty box doesn't read as a hole. The one CSS mistake to avoid: `img { width: 100% }` alone *discards* the attribute ratio — pair it with `height: auto` (or the wrapper's `height: 100%`).

`<video>`, `<iframe>`, and embeds (YouTube, maps, tweets, forms) have no intrinsic size until content loads and often resize themselves. Always wrap them in an `aspect-ratio` box with `overflow: hidden` and give the element `width: 100%; height: 100%`.

## Reserve dynamic regions with minimum mass

A feed, table, chart, or dashboard tile that's empty until data arrives must not be `height: auto`. Give it a `min-height` sized to the *typical filled height*, so the footer and neighbours are already where they'll end up:

```css
.dynamic-feed-container { min-height: clamp(120px, 15vh, 200px); padding: 1.5rem; }
.dashboard-chart        { min-height: clamp(300px, 40vh, 600px); }
```

The exact value comes from the design, not a guess — measure the loaded state and reserve that. A skeleton (`perceived-latency-mask`) inside the reserved box does double duty: it holds the height *and* tells the user what's coming. Ad slots and third-party widgets get a fixed `height` or `min-height` at their largest expected size, reserved even when unfilled.

## The shifts people forget

- **Web fonts.** The largest single shift on an editorial page is usually the headline reflowing when Playfair replaces Georgia. `font-display: swap` alone doesn't fix it — add a fallback `@font-face` with `size-adjust`, `ascent-override`, `descent-override` so the fallback's metrics match. `references/cls-sources.md` has the pattern.
- **Banners injected at the top** (cookie, promo, app-install) push everything down. Reserve the slot in the layout, or make them `position: fixed` overlays that take no flow space.
- **Scrollbars.** When content grows past the viewport, the vertical scrollbar appears and every centred element shifts left. `html { scrollbar-gutter: stable; }`.
- **`content-visibility: auto`** without `contain-intrinsic-size` makes off-screen sections zero-height until scrolled to — the scrollbar jumps as they render. Always pair them.
- **Animating layout properties.** A transition on `height`, `margin`, or `top` is a shift on every frame. `transform` and `opacity` only.
- **Lazy-loading above the fold.** `loading="lazy"` on the hero image delays it past first paint; use `fetchpriority="high"` there and lazy-load only below the fold. Dimensions are still required either way.

## Verify

```bash
python scripts/check_cls.py page.html styles.css
```

Fails on media with no reserved dimensions (attributes, own `aspect-ratio`, or an `aspect-ratio` wrapper), `@font-face` without `font-display`, `content-visibility: auto` without intrinsic size, and transitions on layout properties. Warns on `width`-only image CSS, dynamic-looking containers with no height reservation, lazy images above the fold, missing `scrollbar-gutter`, and fallback fonts without metric overrides. Then confirm in Chrome DevTools → Performance → Layout Shifts, or Lighthouse's CLS audit — target ≤ 0.1.

Attribution

fernandokylasfernandokylas
View sourceMore from fernandokylas →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Responsive Design

Implement modern responsive layouts using container queries, fluid typography, CSS Grid, and mobile-first breakpoint strategies. Use when building adaptive interfaces, implementing fluid layouts, or creating component-level responsive behavior.

393432 votes

Mermaid Diagrams

Creating and refining Mermaid diagrams with live reload. Use when users want flowcharts, sequence diagrams, class diagrams, ER diagrams, state diagrams, or any other Mermaid visualization. Provides best practices for syntax, styling, and the iterative workflow using mermaid_preview and mermaid_save tools.

2032 votes

sleek-design-mobile-apps

Use when the user wants to design a mobile app, create screens, build UI, or interact with their Sleek projects. Covers high-level requests ("design an app that does X") and specific ones ("list my projects", "create a new project", "screenshot that screen").

5711 votes

swiftui-design-skill

SwiftUI frontend visual design skill. Creates beautiful, distinctive iOS/macOS interfaces that avoid generic AI slop patterns. Covers design direction, layout systems, typography, color, spacing, brand integration, and design review. Use when designing new SwiftUI views, reviewing UI quality, creating iOS prototypes, choosing visual styles, improving app aesthetics, or when the UI looks generic or AI-generated.

1801 votes

Ios Hig

Use when designing iOS interfaces, implementing accessibility (VoiceOver, Dynamic Type), handling dark mode, ensuring adequate touch targets, providing animation/haptic feedback, or requesting user permissions. Apple Human Interface Guidelines for iOS compliance.

761 votes
View all in design →