What is a local address and how does it differ from a web address?

Question

This exercise says, “A URL is the web address or local address where a file is stored”. What is a local address and how does it differ from a web address?

Answer

A local address refers to the path to an image, file, or resource that exists on your own computer. A web address on the other hand generally refers to the path to an image, file, or resource that exists externally, on a remote computer.

28 Likes

4 posts were split to a new topic: To adjust the size of the image or align the image to the centre of the page

Thx a lot! Ur answer really helps! :slightly_smiling_face:

5 Likes

Hi! Since you mentioned that a local address refers to the path that the file exists on our computer, by path - do you mean the file location? And in that case, if we move around or edit the file in our computer (say, put it in a different folder, rename the file name, etc), since the path would be different, would that prevent the image from loading or properly rendering?
Thank you so much!

5 Likes

Not so much as the route to the file location.

6 Likes

source on a local address uses file:///path/to/myfile.html
Please note that local address is 3 forward slashes where in http url it is 2 slashes http://

17 Likes

Thank you so much. Your answer made things clearer

Out of interest, does one slash : / have a function? I had to add the space cause it became an emoji. Maybe I answered my own question :confused:

5 Likes

Not in protocol syntax, no. :// separates protocol from URI.

1 Like

How can I type the source of the image stored in the computer?

2 Likes

Let’s look at all the materials we have for finding a solution.

The path of files in our computers are called local address.
The tag for displaying an image is <img src = "file path" />.

So, we need to address the image file in the <img> tag as follows:

<img src="C:\Users\xxxx\Pictures\SamplePic.jpg" />

So, someone may ask another question like how to find the file path in Windows. You can find it by right click on the file and then select the “properties”.

10 Likes

Yes, modifying the name or moving it to another folder or renaming a folder in the mentioned path to the image would prevent the wanted image from loading (and would instead display the text written in the alt attribute of the <img /> tag). If that happens, you need to provide the updated path or name of the image.

To learn more about file paths, visit here:
https://www.internetingishard.com/html-and-css/links-and-images/#absolute-relative-and-root-relative-links

4 Likes

didn’t know until now. thanks

For local address can we only specify the absolute path of the image or relative paths are also supported?

1 Like

Relative paths will work, and are recommended so the HTML can be uploaded to a server and not need to be edited.

Let’s say your work is in the documents folder of your user account:

c:\Users\Documents\Sites\

Each HTML project can have its own site folder:

site1\
  + css\
      - style.css
  + js\
      - script.js
  + images\
      - img.png
  - index.html

In the HTML file (index.html) the path to the style sheet is,

<link rel="stylesheet" href="css/style.css">

The path to JS file will be,

<script src="js/script.js"></script>

The path to the image file:

<img src="images/img.png" alt="">

Note the URL style forward slash. This is supported on your local machine as long as it is in a web file.

5 Likes

how to find the file path in Mac?.

me again, please what are the distinguishing factors between a local address and a web address.

A local address is one on the ‘local machine’, as in one’s own computer. A web address is one that resolves to an IP address on the World Wide Web, as in the internet.