04.06.2013 Views

Head First HTML with CSS

Head First HTML with CSS

Head First HTML with CSS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

How to link to destination anchors<br />

You already know how to link to pages using either relative links or URLs. In<br />

either case, to link more specifically to a destination anchor in a page, just<br />

add a # on the end of your link, followed by the destination anchor identifier.<br />

So if you wanted to link from any Starbuzz Coffee Web page to the “chai”<br />

destination anchor you’d write your element link this:<br />

See Chai Tea<br />

Unfortunately, linking to Chai Tea <strong>with</strong> a destination anchor isn’t very<br />

impressive because the whole page is small enough that it easily fits in the<br />

browser. Let’s link to the Coffee section of http://buzz.headfirstlabs.com<br />

instead. Here’s what you’re going to do:<br />

1 Figure out the id of the destination anchor.<br />

2 Alter the existing element in the Starbuzz Coffee<br />

“index.html” file to point to the destination anchor.<br />

3 Reload your “index.html” page and test out the link.<br />

Finding the destination anchor<br />

To find the destination anchor, you’re going to have<br />

to look at the buzz.headfirstlabs.com page and view<br />

their <strong>HTML</strong>. How? Almost all browsers have a<br />

“View Source” option. So, visit the page and when<br />

it is fully loaded, choose the “View Source” option,<br />

and you’ll see the markup for the page.<br />

In most browsers, you can<br />

right-click to “View Source”.<br />

You’ll also find “View Source”<br />

in the browser menu, usually<br />

under “View”.<br />

getting connected<br />

The main benefit of<br />

destination anchors is to<br />

link to locations in long files<br />

so your visitors don’t have<br />

to scroll through the file<br />

looking for the right section.<br />

you are here 153

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

Saved successfully!

Ooh no, something went wrong!