04.06.2013 Views

Head First HTML with CSS

Head First HTML with CSS

Head First HTML with CSS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

working <strong>with</strong> paths<br />

Planning your paths...<br />

What do you do when you’re planning that vacation<br />

in the family truckster? You get out a map and<br />

start at your current location, and then trace a path<br />

to the destination. The directions themselves are<br />

relative to your location – if you were in another city,<br />

they’d be different directions, right?<br />

To figure out a relative path for your links, it’s the<br />

same deal: you start from the page which has the<br />

link, and then you trace a path through your folders<br />

until you find the file you need to point to.<br />

Let’s work through a couple of relative paths (and<br />

fix the lounge at the same time):<br />

Linking down into a subfolder<br />

1<br />

2<br />

Linking from “lounge.html” to “elixir.html”.<br />

60 Chapter 2<br />

about<br />

<br />

.<br />

.<br />

.<br />

<br />

directions.html<br />

lounge<br />

beverages<br />

Okay, you’d<br />

really go to<br />

Google maps,<br />

but work<br />

<strong>with</strong> us here!<br />

We need to fix the elixirs link in the “lounge.html” page. Here’s what the<br />

element looks like now:<br />

elixirs<br />

Identify the source and the destination.<br />

There are other kinds of<br />

paths too. We’ll get to<br />

those in later chapters.<br />

When we re-organized the lounge, we left “lounge.html” in the “lounge” folder, and<br />

we put “elixir.html” in the “beverages” folder, which is a subfolder of “lounge”.<br />

<br />

.<br />

.<br />

.<br />

<br />

lounge.html<br />

<br />

.<br />

.<br />

.<br />

<br />

elixir.html<br />

Start here...<br />

images<br />

...and find a<br />

path to here.<br />

Right now we’re just using the<br />

filename “elixir.html”, which tells<br />

the browser to look in the same<br />

folder as “lounge.html”.<br />

drinks.gif<br />

green.jpg<br />

blue.jpg<br />

lightblue.jpg<br />

red.jpg

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!