Skip to content
Learn Netverks

Lesson

Step 27/58 47% through track

file-paths

File paths

Last reviewed May 28, 2026 Content v20260528
Track mode
iframe_html
Means
HTML preview sandbox
Reading
~2 min
Level
advanced

This lesson

This lesson teaches File paths—the ideas, syntax, and habits you need before moving on in HTML.

Without a solid grasp of File paths, you will repeat mistakes in HTML exercises and on real pages or scripts.

You will apply File paths in contexts like: Websites, hybrid apps, email templates, design systems, and CMS-driven content.

Read the lesson, edit HTML/CSS in the playground, press Run to preview, then answer the lesson MCQs. Also use the HTML reference desk when you need tag or attribute lookup.

When intermediate lessons feel comfortable and you are ready for production-style trade-offs.

Paths describe how to locate resources relative to URL hierarchies. Mixing strategies confuses deployments—pick conventions per project.

Kinds

  • Absolute URL: includes scheme/host/path—required for cross-origin assets.
  • Protocol-relative: deprecated pattern (//cdn)—prefer explicit HTTPS.
  • Site-root-relative: begins with /; resolves from domain root.
  • Document-relative: walks from current file (../img/a.png).

Fragment URLs

guide.html#setup jumps to id="setup" after navigation.

Query strings

?q=html&sort=asc supplies parameters—encode reserved characters.

Servers & case sensitivity

Linux hosts treat paths as case-sensitive even if macOS dev machines do not—normalize filenames early.

Static hosting vs frameworks

Framework routers often prepend base paths (/blog/). Align asset prefixes with deployment targets.

Deployment footguns

  • Trailing slash policies differ—relative links break when servers redirect between /page and /page/.
  • Assume Linux case sensitivity everywhere even if teammates develop on macOS defaults.
  • Hash routes (#-only SPA paths) confuse server analytics—establish canonical logging early.

Resolved URL examples

Assume the current document URL is https://example.com/learn/html/paths/

Href in markupResolves to
`/assets/logo.svg`https://example.com/assets/logo.svg
`page2`https://example.com/learn/html/paths/page2
`../css/app.css`https://example.com/learn/css/app.css
`#toc`Same path + fragment (#toc) on navigation

Important interview questions and answers

  1. Q: What is the practical difference between `id` and `class`?
    A: `id` must be unique and is used for fragments/labeling; `class` is reusable for styling and behavior grouping.
  2. Q: Why is `defer` commonly preferred for scripts?
    A: It preserves HTML parsing, executes after parse, and avoids blocking rendering unlike classic synchronous scripts.
  3. Q: How do `srcset` and `sizes` work together?
    A: `srcset` provides candidate files and `sizes` tells expected rendered width so the browser can pick an optimal resource.

Tip: Prefer root-relative paths (/assets/app.css) in deployed apps.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • What confused you about this lesson?
  • How would you explain this to a teammate in 30 seconds?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump