Harvard Extension School
CSCI E-12 Fundamentals of Web Site Development | Spring 2019

## Resolving Relative Links

In the case of relative URLs, the information not expressed in the relative URL is derived from the current URL location.

### Resolving Relative Links 1

Simple relative link.

Current Location:
http://www.acme.com/products/road_runner_traps/model_a.html

That contains the link:
model_b.html

Resolves to:
http://www.acme.com/products/road_runner_traps/model_b.html

### Resolving Relative Links 2

Relative link that uses "../" to "move up" the the URL path of the current URL.

Current Location:
http://www.acme.com/products/road_runner_traps/model_a.html

That contains the link:
../images/model_a.png
Note that the `..` is a way to "move up" the URL path (the URL path is divided by `/`).

Resolves to:
http://www.acme.com/products/images/model_a.png

### Resolving Relative Links 3

Relative URL that uses scheme and host from of the currrent URL.

Current Location:
http://www.acme.com/products/road_runner_traps/model_a.html

That contains the link:
/css/screen.css
Note that the `/` at the beginning of the relative URL means that we start from host and scheme provided by the current location -- the relative URL is proving the complete path.

Resolves to:
http://www.acme.com/css/screen.css

Copyright © David Heitmeyer