<A Href=“ to Yahoo!</A> Hyperlinks Can “Link” To
Total Page:16
File Type:pdf, Size:1020Kb
Hyperlinks can “link” to: Other web pages Images Files Places in the same document E-mail address A hyperlink is a word, phrase, or image that you can click on to jump to a new document or a new section within the current document. Hyperlinks are found in nearly all Web pages, allowing users to click their way from page to page. Text hyperlinks are often blue and underlined (that’s the default), but can be styled to be a different color. When you move the cursor over a hyperlink, whether it is text or an image, the arrow should change to a small hand pointing at the link. When you click it, a new page will open or the browser will jump to a place in the current page. After a hyperlink is clicked, it changes to a “visited” link and is purple by default. Paths There are two types of paths in HTML, known as relative paths and absolute paths. An absolute path contains the full URL of the item being referenced (starting with the http:// part). A relative path contains directions to the item relative to the HTML page. If it is in the same folder, it’s just the filename. This path will always be in quotation marks in the HTML tag. Anchor Tags The HTML tag used to create a hyperlink is an anchor tag, which is simply an A. However, an anchor tag can’t do anything on its own. You must also specific a hyperlink reference (where it is linking to) and the words (or image) that will be clicked on to take you there. For instance if you wanted the words Go To Yahoo! to actually link you to Yahoo’s site, your code would be: <a href=“http://www.yahoo.com”>Go to Yahoo!</a> http://art.wallyzone.com/dm60a/tutorials/anchor.shtml 26 Created by Tonya Skinner, Creative Commons License TRY IT Online HTML Editor: OUT! http://htmledit.squarefree.com/ Here is an example using all absolute references. Notice each hyperlink reference points to an actual website URL, starting with http://. Notice that after the “clickable” words, the hyperlink anchor (the A) is turned off. If you forget to turn off the </a> then the entire page after that will be underlined….that’s not good stuff. :) The final link a direct link to the URL for an image. You can link to any type of file. (NOTE: The HTML structure codes are omitted below to focus simply on the hyperlink coding) Relative References Note that all of these HTML files are saved in the same folder. See hyperlinkpages folder. 27 Created by Tonya Skinner, Creative Commons License Relative Hyperlink References Whatever folder index.html is in would be the parent folder. About and Products are child folders. Computers and printers are child folders of product, but grandchild folders of the main folder. http://faculty.scf.edu/bourenv/lessons/lesson02_1.html 28 Created by Tonya Skinner, Creative Commons License E-mail Hyperlink To create a link that starts up the user’s email program and addresses and e-mail t a certain address, you use the anchor element. However, this time the value of the href attribute starts with mailto: and is followed by the email address you want. Many sites do this, but just note that if the user doesn’t have email set up on their computer, it will typically ask them to set it up, which can be annoying .It won’t allow the user to use a web-based email program. <a href=“mailto:[email protected]”>E-mail Me!</a> Named Targets You’ve probably seen websites where you can “jump” down the page to go to a certain section, like a mini table of contents at the top of the page that takes you to specific paragraphs or sections further down the page. The hyperlink is a relative one, preceded by a pound sign #: <a href=“#section1”>Read Section One</a> However, for it to actually work, you have to name the target later on down the page. This is done by using an ID attribute inside another tag. You can use an anchor tag, or if you are jumping down to a heading, for example, you can put it in there. <a id=“section1”><p>Section 1</p></a> Or <h2 id=“section1”>Section 1</h2> Special Attributes for Hyperlinks When you click a hyperlink, by default it opens in the same window, replacing your currently displayed page. You can add a special attribute inside the anchor tag that will target it to open in a new window (or new tab, depending on your browser settings). Then, your user won’t have to click the back button to return to the previous page; they’ll need only to close the newly opened windows. This attribute is the target attribute. You set target to _blank to open in a new window as follows: <a href=“page4.html” target=“_blank”>Click here</a> Notice multiple attributes are separated by a single spacebar. One other attribute you can add is the title attribute. This works just like the <abbr> tag we’ve used in the past, and makes “popup” text when you point to the link. <a href=“page4.html” target=“_blank” title=“Click Me!”>Click here</a> 29 Created by Tonya Skinner, Creative Commons License Save as target.html. Solution is in TRY IT hyperlinkpages folder. OUT! When viewing the page in the browser, size the browser down so when you click the links, the page can reposition. If the page fills the entire screen, it cannot exactly “jump down.” 30 Created by Tonya Skinner, Creative Commons License .