[ Pobierz całość w formacie PDF ]
.Using the same example, to link to the file index.html in a higher level directory(web), I could use the relative pathname to that file as shown:Simple Hypertext Links 133Web Design in a Nutshell, eMatter EditionCopyright © 2000 O Reilly & Associates, Inc.All rights reserved.Linking Within a DocumentThis relative URL is the equivalent to the absolute URL http://www.littlechair.com/web/index.html.Linking Within a DocumentBy default, when you link to a page, the browser displays the top of that page.Toaid in navigation, you can use the anchor tag to link to a specific point or sectionwithin a document.This is a two-step process.Naming a fragmentFirst, you need to identify and name the portion of the document (called a frag-ment) that you want to link to.The fragment is marked using the anchor () tagwith its name attribute, giving the document fragment a name that can be refer-enced from a link.To illustrate, let s set up a named fragment within a sample document calleddailynews.html so users can link directly to the Stock Quotes section of the page.The following anchor tag marks the Stock Quotes title as a fragment named stocks.Daily Stock QuotesLinking to a fragmentThe second step is to create a link to the fragment using a standard anchor tagwith its href attribute.Fragment identifiers are placed at the end of the pathnameand are preceded by the hash (#) symbol.To link to the stocks fragment from within dailynews.html, the link would looklike this:Check out the Stock QuotesLinking to a fragment in another documentYou can create a link to a named fragment of any document on the Web by usingthe complete pathname.(Of course, the named anchors would have to be in placealready.) To link to the stocks section from another document in the same direc-tory, use a relative pathname as follows:Go to today s Stock QuotesUse an absolute URL to link to a fragment on another site, as in the followingexample:Using named anchorsNamed anchors are most often used as a navigational aid by creating a hyper-linked table of contents at the top of a very long scrolling web page.Users can seethe major topics at a glance and quickly get to the portions that interest them.134 Chapter 8 Creating LinksWeb Design in a Nutshell, eMatter EditionCopyright © 2000 O Reilly & Associates, Inc.All rights reserved.Affecting the Appearance of LinksWhen linking down into a long page, it is generally a good idea to add links backto the top of the page or to the table of contents.Note that the HTML 4.0 Specification allows any element on a web page to betargeted by its ID value just as though it were a named anchor.The first linedemonstrates a heading that includes an ID identifier.The second line is a link onthe same page to that particular heading.IntroductionReturn to the IntroductionAffecting the Appearance of LinksAs we all by now know, linked text is blue and underlined by default andgraphics are identified by blue borders (unless you turn them off).But it doesn thave to be that way! Changing the color of links is easy with HTML, so you canmake your links more coordinated with your chosen site palette.Style sheets offereven more control over the appearance of links.You should exercise some caution in changing link appearance.The blue text andunderlines have become a strong visual clue for click here, so altering thisformula may confuse your users.Use your knowledge of the savvy of your targetaudience to guide your design decisions.Setting Colors inLink color specifications in the tag are applied to the whole document.Links Sets the color for hyperlinks.Thedefault color for links is blue.Visited links Sets the colors for links that havealready been clicked.The defaultcolor for visited links is purple.Active links Sets the color for a link while it is inthe process of being clicked.Thedefault color for an active link isred.Specifying Color for a Specific LinkYou can override the color of a specific link by placing tags within theanchor tags
[ Pobierz całość w formacie PDF ]