Home  >  Article  >  Web Front-end  >  How to Access Files in a Parent Directory from an HTML File?

How to Access Files in a Parent Directory from an HTML File?

Patricia Arquette
Patricia ArquetteOriginal
2024-11-08 22:23:02577browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn