Home > Web Front-end > CSS Tutorial > 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
Release: 2024-11-08 22:23:02
Original
610 people have browsed it

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');
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template