Home > Article > Web Front-end > How to Access Files in a Parent Directory from an HTML File?
Accessing Files One Directory Up in HTML
When creating a website, it's common to segregate files into subdirectories based on their purpose. For instance, style sheets might be kept in a "styles" directory, while images reside in an "images" directory.
To reference a file in a different directory from within a style sheet, you need to indicate the parent directory. This involves using ".." to navigate up one level in the directory structure.
For example, suppose your style sheet is located in "root/styles" and you want to reference an image in "root/images." The correct path to use in your CSS file would be:
background-image: url('../images/bg.png');
By using "..", you are instructing the browser to go one level up in the directory structure from "styles" to "images" and then load the specified file.
The above is the detailed content of How to Access Files in a Parent Directory from an HTML File?. For more information, please follow other related articles on the PHP Chinese website!