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 HTML Basics Going Further with HTML Root-relative Paths

Root relative and relative file path

Is someone able able to explain me the advantage of using root relative path to relative file path? Thanks in advance!

Max Klopsch
Max Klopsch
22,628 Points

Say your CSS file is at the root of the website: example.com/styles.css but you are on the following page example.com/contact. If you use the relative file path to the css href="styles.css" the browser won't be able to find the file because it will look at example.com/contact/styles.css In this case the root relative file path href="/styles.css" will let the browser know to look at the root of the website so at example.com/styles.css and be able to find the file.

1 Answer

Hi Victor;

I added a link that explains the differences between:

  1. Absolute File Paths
  2. Relative File Paths
  3. Root Relative Paths

Follow this link: Absolute File Paths VS. Relative File Paths VS. Root Relative Paths

Hope this answers your question.

Manny