The most fundamental truth is this: A website is not one single file. It's a collection of different files (HTML, CSS, JavaScript, images, videos, fonts) that all need to work together. These files are organized into folders, just like documents on your computer.
Now we have a core problem: If your index.html file needs to display an image named logo.png, how does the HTML file tell the browser where to find logo.png? You can't just say src="logo.png" and expect it to work every time. What if the logo is in an images folder? What if it's on a completely different website? The browser needs an exact, unambiguous address to locate the file. A file path is that address.
A relative file path gives directions to a file starting from the location of the file you are currently in. You will use this 99% of the time for linking your own files together (images, CSS, other HTML pages).
Here are the different scenarios:
An absolute file path gives the full, complete URL to a resource on the web. It starts with http:// or https://.
When to use it: You ONLY use absolute paths when you are linking to a resource that is NOT on your own website.
Example:
A beginner might be tempted to copy the full path from their computer, like this: src="C:/Users/Arjun/Desktop/my-website/images/logo.png"
This is a major mistake. This address only works on your computer. The moment you upload your website to a real web server, that path becomes meaningless and the image will be broken.
The fundamental truth is that a web browser is a program that needs specific, predictable instructions to do its job. It cannot guess your intentions. You can't just give it a file with a <h1> tag and expect it to know what kind of document it is, what language it's in, or how to render it properly.
We need a way to give the browser essential "setup information" before it starts rendering our visible content (like paragraphs and images). This setup information needs to answer critical questions:
Just writing "Hello" doesn't answer any of these questions.
The solution is to create a standard, universal starting template—a boilerplate. This is a block of code that you will start every single HTML file with. It's not something you need to reinvent each time; you just copy-paste it and fill in the blanks. It's the "blueprint of the house" that you need before you can start putting in the walls h1 and windows img.
Let's build the modern HTML5 boilerplate from first principles:
Let's break down each line and explain why it's necessary.
The logical solution is to invent two types of labels (which we call attributes) that you can add to any HTML tag.
Analogy: