HTML filsti
- Previous page HTML JavaScript
- Next page HTML header
Sti | Beskrivelse |
---|---|
<img src="picture.jpg"> | picture.jpg findes i samme mappe som den nuværende webside |
<img src="images/picture.jpg"> | picture.jpg findes i mappen images i den nuværende mappe |
<img src="/images/picture.jpg"> | picture.jpg findes i mappen images i den nuværende stations rootmappe |
<img src="../picture.jpg"> | picture.jpg is located in the parent folder of the current folder |
HTML filsti
File paths describe the location of a file in the website folder structure.
File paths are used when linking external files:
- Web page
- Image
- Stylesheet
- JavaScript
Absolute file path
An absolute file path is a complete URL pointing to an internet file:
Example
<img src="https://www.codew3c.com/images/picture.jpg" alt="flower">
The <img> tag and the src and alt attributes are explained in the HTML images chapter.
Relative path
Relative paths point to files relative to the current page.
In this example, the file path points to a file in the images folder located in the root directory of the current website:
Example
<img src="/images/picture.jpg" alt="flower">
In this example, the file path points to a file in the images folder located in the current folder:
Example
<img src="images/picture.jpg" alt="flower">
In this example, the file path points to a file in the images folder located in the parent folder of the current folder:
Example
<img src="../images/picture.jpg" alt="flower">
Good habit
It is a good habit to use relative paths if possible.
If you use a relative path, your web page will not be bound to the current base URL. All links can work normally on your computer (localhost) or in the future public domain.
- Previous page HTML JavaScript
- Next page HTML header