Zum Inhalt springen
Skillpedia
Websites & UI (Frontend)75k · #2815

dimensions

Was er macht

Dieser Skill prüft Bild-Tags auf Website auf fehlende Größenangaben. Er ist für Entwickler gedacht, die Seiten wollen, die beim Laden stabil bleiben.

Wann du ihn nutzt

  • ✓Wenn Inhalte auf deiner Seite springen, während Fotos fertig laden.
  • ✓Wenn du neue Bilder zu einer Seite oder Vorlage hinzufügst.
  • ✓Wenn deine Seite bei Prüfungen zur Layout-Stabilität schlecht abschneidet.

Link zum Skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/dimensions/SKILL.md

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/dimensions/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Kannst du Bilder auf meiner Website finden, denen Breite und Höhe fehlen?”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Der Agent durchsucht die Bild-Tags und meldet jene ohne Breite oder Höhe. Er schlägt vor, die echten Abmessungen des Bildes anzugeben, damit der Browser den Platz reserviert, bevor das Bild lädt.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von GitHub.

Set explicit width and height on images

Images without explicit dimensions are the most common cause of Cumulative Layout Shift (CLS), a Core Web Vitals metric. When images load and cause layout jumps, users accidentally click the wrong element—a frustrating experience that Google penalises in search rankings. A CLS score above 0.1 is considered 'needs improvement'; above 0.25 is 'poor'.

Quick Reference

  • Reserve findings for meaningful content images; decorative micro-SVGs or ornament-only assets are low-priority exceptions when CSS already reserves stable space
  • Example low-risk exception: <img src="/divider.svg" alt="" aria-hidden="true"> should not be flagged on its own without evidence of visible layout shift
  • Always set width and height attributes on <img> matching the image's intrinsic dimensions
  • Pair with height: auto in CSS to keep the image fluid while preserving the aspect ratio
  • Missing dimensions are the leading cause of Cumulative Layout Shift (CLS) from images
  • Browsers derive aspect-ratio from these attributes—do not set arbitrary placeholder values

Check

Scan all <img> elements in the codebase. Identify any that are missing either the width or height attribute. Also check <source> elements inside <picture>—dimensions should be on the <img> fallback. Report each image missing dimensions with its file path and line number. Note: SVG icons under 32px, tiny decorative SVG ornaments with stable CSS sizing, and images loaded as CSS backgrounds are exempt.

Fix

For each <img> missing width/height: 1) Add the intrinsic pixel dimensions as attributes (e.g., width="800" height="450"). 2) Use CSS max-width: 100% and height: auto on the element to keep it responsive. 3) The attribute values must match the image's intrinsic aspect ratio—do not set arbitrary numbers. 4) For dynamically sized images, calculate the aspect ratio and use the CSS aspect-ratio property as a fallback. 5) Skip purely decorative micro assets when the snippet already shows stable sizing and there is no evidence of layout shift risk. Show the before and after HTML for each fixed image.

Explain

Explain why width and height attributes on <img> prevent Cumulative Layout Shift (CLS). When a browser parses HTML, it does not yet know an image's dimensions—without explicit attributes, the browser initially renders a 0-height placeholder, then jumps the layout when the image loads. With width and height set, the browser calculates the aspect ratio from the attributes and reserves space immediately, eliminating the shift. This became especially important as modern browsers use the aspect-ratio CSS property derived from these HTML attributes.

Code Review

Review image assets, markup, and delivery configuration related to Set explicit width and height on images. Flag exact files or components where format choice, sizing, or loading behavior violates the rule, and describe how to confirm the fix in DevTools.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/images/dimensions

Häufige Fragen

Warum ist ein Bild ohne Größe ein Problem?

Der Browser weiß nicht, wie viel Platz er freihalten soll, deshalb rutscht der Text darunter, sobald das Bild erscheint.

Zählen kleine dekorative Icons auch?

Der Skill behandelt winzige dekorative Bilder als niedrige Priorität, weil sie selten den Inhalt um sich herum verschieben.

Welcher Wert gilt als gut?

Der Skill sagt, ein Layout-Verschiebungswert unter 0,1 gilt als gut, über 0,25 als schlecht.

Details

Originalbeschreibung des Autors

Use when reviewing image assets, markup, and CDN or build transforms related to Set explicit width and height on images. Check encoded size, rendered size, loading strategy, and above-the-fold impact together. Separate real CLS risks from tiny decorative SVGs or ornament-only assets that are unlikely to move surrounding content.

repo: thedaviddias/Front-End-Checklist

Beliebtheit

GitHub-Sterne
75k
Platz im Ranking
#2815
Lizenz
MIT
Aktualisiert
31.10.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills