Relative path: parent directory


#1

https://www.codecademy.com/paths/web-development/tracks/getting-more-advanced-with-design/modules/learn-css-typography/lessons/css-typography/exercises/font-face-iii

In this exercice, the relative path to the font-family is

…/fonts/Glegoo-Regular.ttf

Why? since “fonts” is in the same file as " index.html", fonts/Glegoo-Regular.ttf should be enough no?


#2

The fonts folder is in the same directory as index.html, yes, but to access it from inside the css folder, we need to get back into its parent, then traverse into the fonts folder.

src: url(../fonts/Glegoo-Regular.ttf) format('truetype');

#3

so it is because style.css is in “styles” folder so we need to go back to their parent folder.

But if style.css wasn’t in a folder, just “fonts/Glegoo-Regular.ttf” would do. Did I get the logic right?


#4

Safe to say, yes. It depends where the CSS file is. The path needs to be relative to it, not the index.html file.