Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Dont understand root relative path

what does root relative path mean? can somebody explain it for me?

and what does document relative path or links mean?

2 Answers

Steven Parker
Steven Parker
231,248 Points

When they say "root relative" they mean the system looks for the file in the "root" folder for the system. This is usually a configuration parameter for the server. A root relative path will begin with a slash ("/") character.

On the other hand, "document relative" means it will look for the other file in same folder as where the current page was loaded from. A document relative path will begin with a name of the file or a subfolder.

i think i know what you mean but can you make an example or visual presentation about this?

Steven Parker
Steven Parker
231,248 Points
<!-- these are "document relative" paths -->
    <img src="face.jpg">
    <img src="pets/bingo.jpg">
<!-- this is a "root relative" path -->
    <img src="/images/label.jpg">

ok i think i understand what "document relative" path is. from your example:

<!-- these are "document relative" paths --> <img src="face.jpg"> <img src="pets/bingo.jpg">

the image face.jpg has no document am i right? and the bingo pic has a document, it is inside in the folder called pets. But i dont know why they are called document relative path?

and when it comes to root relative" path i undestand that the pic is inside a folder called images but i dont know why it has a / in the beginning? and why are they called root relative?

sorry english is not my first language :(

Steven Parker
Steven Parker
231,248 Points

Not quite, the "document" is always the page that is currently being viewed.

And the / in the beginning of a "root relative" path refers to the root folder.