What does "root of the current web" or "current sub directories" mean in HTML?

I don't get this.

I am trying to understand how the file paths work, but i don't get what this "root of the current web" means? Where exactly is that folder located?

The only thing that makes sense to me is that, i am targeting a picture that is opened in another sub-page of my website, and so it doesn't matter where that folder is located.

I.e. If i have uploaded a picture from my computer on one of my many pages on my website, and then i make another page, and want to use the same pic, instead of writing the path of my computer, i write the path of my page in which the pic is located, and the code takes the pic from the other page, is that correct?

And that won't work if i don't have other pages, right? I tried to write the path of another separate page, not a sub-page, and it didn't work. So, what is a sub-page in this case?

4 Answers

  • 1 month ago
    Favourite answer

    When you create a web page, you first have to create a folder that will hold all the files for that page.  That folder is called your "root" folder.  It is going to be where ever you create it.  because no one can predict were it is or what you will call it, HTML simple refers to it as "root."

    When creating a web page, may designed will put each page of the site in its own folder.  That makes it easier for them to keep all the files for that page together in one location.  they may also have a folder that has shared elements, such as an image that appears in the header of every page, a logo, etc.  Each of those folders is considered a sub folder or sub directory under that root folder/directory.  When you are working on a page, you normally have the folder with the files for that page open as your "current sub directory".  

    Say your web site is in a folder called "MySite".  That would be your "root" folder.  Inside of that you create a folder "Page1", and folder "Page2" and a folder "SharedIamges".  Each of those would be a sub folder or sub directory.

    You go into the folder "Page1" and start working on the HTML for that page.  You want to add two images to the page.  One (pic1) is in the same folder as the web page.  The other (pic2) is in the "MySite"  Pic1 would be in the "current sub directory" because it is on the same directory as the page you are creating.  The other would be in the "root of the current web" because it is in the original folder that holds everything ("the root").  

    You can reference pic1 by just using its name since it is in the same folder as the HTML code.  But you would have to reference \pic2 to reach the second picture because it is in the root of the web site.

  • 1 month ago

    Things do not normally come from "within" other pages.

    HTML files are just plain text. Any image or photo is a separate file with its location referenced in the html content, so the web browser program can get that and display it in the appropriate part of the page.

    The "root of the current page" is wherever the main file for that page is located (the directory it is in, on the web server).

    Paths are to _directories_ containing files, not anything out of another page.

    eg. So if the site index page is in "public_html" (as is common with cpanel based web hosts);

    That's the web site root directory and normally where your index.html or index.php file would be.

    If you create a directory in the server root eg. called photos, then the path for an image from in index.html would just be like "photos/image.jpg" 

    If your index page had links to other html or php page files in a different subdirectory, eg. "pages", then to used a picture in the photos directory, you would have to use "../photos/image.jpg

    The double dot means "up a level" taking it back the the site root in public_html, then it goes in to photos and can use the image file.




    Depending on the web hosts system, you may be put directly in to the site root, or it could be a different name than public_html.

    It's wherever the host documents say to put the main site "index.html" file.

    • ILoveCoffee
      Lv 5
      1 month agoReport

      Thanks. I get it now. 

    • Commenter avatarLog in to reply to the answers
  • keerok
    Lv 7
    1 month ago

    Yes, you can access an image from another folder or page in your website. You only have to get a better understanding of HTML file paths and website folder structures. 

    There are two ways to access a file in the web - absolute and relative. Read more about it here.


    If you keep bumping into problems, access the picture from it's original page, right-click on the image, copy image address, then paste that as the URL in the other page's html file.

    • Commenter avatarLog in to reply to the answers
  • Anonymous
    1 month ago

    The internet does not have a root it is not a tree structure but a web!

Still have questions? Get answers by asking now.