OnlineCBT Logo OnlineCBT
HTML Tutorial
HTML · LESSON 18

Image Paths and Best Practices

By Ratan Updated: 16 Oct 2026

Manage image asset directories, file formats (PNG, JPEG, WebP, SVG), and loading optimizations.

Level: Beginner to Advanced
Duration: ~60 Mins Deep-Dive

1. Organizing Image Directories

In production web projects, never place image files in the root folder alongside HTML files. Establish a structured directory hierarchy:

project-root/
├── index.html
├── courses.html
└── assets/
    ├── images/
    │   ├── banners/
    │   ├── icons/
    │   └── thumbnails/
    └── css/

2. Choosing the Right Modern Image Format

Format Best For Transparency Animation
WebP / AVIF Modern photos & illustrations (30-50% smaller than JPEG). Yes Yes
SVG Logos, icons, vector graphics (infinitely scalable). Yes CSS-driven
PNG Screenshots and graphics requiring lossless transparency. Yes No
JPEG / JPG Photographs and complex gradients. No No

3. Image Best Practices Checklist

  • Compress all images using tools like TinyPNG or Squoosh before committing them to production.
  • Use descriptive, lowercase filenames separated by hyphens (e.g., physics-mock-test-card.webp rather than IMG_0042.jpg).
  • Always test relative file paths across both Windows backslashes and Linux forward slashes (web servers always require forward slashes /).

📝 Live Lesson Practice

HTML/CSS JavaScript Python C++ C PHP
⌨️ Practice Inputs (लाइव इनपुट भरें) (खाली होने पर RED, भरने पर GREEN underline)
💻 Code Editor (Monaco VS Code Engine)
👀 Live Preview
Address Contact

+91 7877547686

E-mail

onlinecbtportal@gmail.com

Helpline Number

+91 7877547686


Click To Download
Get it on Google Play

ऐप डाउनलोड करने
के लिए Google Play पर
उपलब्ध है

WhatsApp Chat