π¨ Images & Media Β· Module 4
codecratsworl.dev β visual storytelling
A picture is worth a thousand words.
Add motion, sound & magic with the right formats, attributes, and style.
πΈ image file format Β© copyright π license
ποΈ gif / jpeg / png π resolution πΌοΈ foreground
π height & width π alternate text π¬ title
π link images π caption π¨ border / padding / margin
β¨ background π transparency π animation
ποΈ compression
πΌοΈ Formats & Attributes
π JPEG Β· PNG Β· GIF
alt="Mountain landscape" + title="tooltip"
Explicit width="320" height="180" prevents layout shift.
<img src="landscape.jpg" alt="mountain lake"
title="JPEG with good compression"
width="320" height="180">
π¨ Styling Foreground
border:3px solid #2c7da0 | padding:5px | margin:0.5rem
β¨ background-color on wrapper + transparent PNG effect
Use object-fit: cover to preserve aspect ratio.
.styled-img {
border: 3px solid #2c7da0;
padding: 5px;
margin: 0.5rem;
background: #f0f6fa;
}
π Linked Images & Captions
πΎ Figure 1: Creative Commons licensed β click image to view original
<figure>
<a href="high-res.jpg"><img src="thumb.jpg" alt="..."></a>
<figcaption>Caption with credit</figcaption>
</figure>
β¨ Transparency & Background
π§© PNG transparency overlay + compression
β
Transparency: PNG vs JPEG. Use PNG for logos & icons.
β
Compression: JPEG for photos, WebP for modern sites.
π¬ Motion, Sound & Magic
β¨ background-image + magic overlay
π Animated GIF β lightweight motion, no video tag needed.
Use with care for performance. Pair with alt text for accessibility.
<img src="animation.gif" alt="demo animation">
π Height, Width & Caption
π Figure caption: "Leaf macro β resolution responsive + height hints"
π§ Best practice: Always specify width and height attributes to avoid Cumulative Layout Shift (CLS).
Combine with CSS max-width: 100%; height: auto; for responsiveness.
π Copyright, Licenses & File Format Guide
π Image Licensing
Creative Commons (CC0, BY, SA)
Royalty-free vs Rights-managed
Public domain & free stock sites
Always attribute when required
ποΈ Format Specs
JPEG: Photographs, millions of colors, lossy compression.
PNG: Transparency, sharp edges, lossless, larger file size.
GIF: Animation, limited 256 colors, supports transparency.
WebP/AVIF: Modern compression + transparency.
ποΈ Resolution & Compression
Display resolution (72-96 DPI for web) vs print. Use tools to compress JPEG/PNG without quality loss. Optimize for speed + user experience.
ποΈ Foreground Image: Border Β· Padding Β· Margin In Action
border:5px + padding:8px
margin:20px + border-radius:50%
dashed border + padding:4px
img {
border: 5px solid #ffae5a;
padding: 8px;
margin: 0.5rem;
background: #fff3e0;
border-radius: 16px;
}
π Web superpower: βMotion, Sound & Magic β virtually unlimited availability of content.β Use audio, video, and animated images ethically, respect copyright, and provide accessible alternatives.