The file path in HTML, the absolute and relative image links

The file path in HTML, the absolute and relative image links


The file path in HTML is used to describe the location of the file in the site’s directory structure. Refer to the following article of Taimienphi.vn to learn the file path details in HTML.


In the following article, Taimienphi.vn will introduce you further The file path in HTML. Also readers can refer to some other articles already on Taimienphi.vn to learn about JavaScript in HTML.

Types of file paths in HTML

Table of Contents:

1. The file path in HTML
2. Absolute file path in HTML
3. The relative file path in HTML
4. Some notes when using file paths in HTML

1. The file path in HTML

The file path in HTML is used to describe the location of the file in the site’s directory. We can imagine the file path as the file address for the web browser. To link external resources and add to HTML files, we can use file paths such as images, files, CSS files, JS files, videos, etc.

Properties src good href requires an extra attribute to link external sources to HTML files.

The following table contains the file path types in HTML:

file path in html

The file path is used on websites to link external files like:

– Web pages

– Images

– Style sheets

– JavaScript

There are two types of file paths in HTML, including:

– Type 1. Absolute File Path (Absolute File Path).

– Type 2. Relative File Path (Relative File Path).

file path in html 2

2. Absolute file path in HTML

The absolute file path in HTML specifies the full URL.

For example: Here is an example of the absolute file path in HTML:

file path in html 3

The result returned after using the absolute file path is as follows:

file path in html 4

file path in html 5

3. The relative file path in HTML

The relative file path in HTML specifies a file that is relevant to the position of the current page.

Example 1: Refer to the example relative file path in HTML below:

In the example below the file path points to a file in the image directory located in the root of the current web page.

file path in html 6

The result will look like this:

file path in html 7

Example 2: In this example, the file path points to the file in the image directory located in the current directory:

file path in html 8

The result will look like this:

file path in html 9

Example 3: In this example the image folder is in the same folder as the current folder:

file path in html 10

The result will look like this:

file path in html 11

file path in html 12

4. Some notes when using file paths in HTML

– Do not forget to use the URL, file name, image name properly, otherwise these elements will not show up on the site.

– Use relative file paths to code independently of the URL.

https://thuthuat.taimienphi.vn/duong-dan-file-in-html-50704n.aspx
The article above Taimienphi.vn has just introduced you to the file path in HTML. Also readers can refer to some other articles already on Taimienphi.vn to learn about properties id in HTML. In the next articles, Taimienphi.vn will introduce you more about head element in HTML.

.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *