• No results found

Creating a Basic Link

To create a hyperlink, you need three things:

The Web address (called a Uniform Resource Locator, or URL) of the place you want to link to.

Some text in your Web page to hang the link on. Usually, the text you attach a link to describes the resource being linked.

An anchor element (<a>) to bring it all together. The element you use to create links is called anchor element (as opposed to the link element) because you use it to anchor a URL to some text on your page. When a user views your page in a browser, he or she can click the text to activate the link and jump to the page whose URL you specified in the link.

Say you have a Web page that describes HTML standards. You might want to refer Web surfers to the World Wide Web Consortium (W3C) - seeing as it's the organization that governs all things related to the HTML standard - for detailed information. A basic hyperlink to the W3C's Web site, www.w3.org, looks like this:

<p>The <a href="http://www.w3.org">World Wide Web Consortium</a> is the standards body that oversees the development of the HTML specification.</p>

You specify the link URL (http://www.w3.org) in the anchor element's href attribute. The text (World Wide Web Consortium) you include between the anchor element's open and close tags (<a> and </a>) is the text you hang your link on. Figure 5-1 shows how a browser displays this bit of markup.

Figure 5-1: A paragraph with a link to the W3C.

Tip You can also anchor URLs to images so users can click the image to activate a link. (For more about creating images that link, see Chapter 6.)

For a detailed discussion of the ins and outs of URLs, see Chapter 1.

Anchor elements aren't block elements

Notice, in the W3C link example, that the anchor element sits inside a paragraph (<p>) element. Anchor elements are inline elements - they don't define blocks of text, but instead apply to a few words or characters within a block of text. When you create a link, you should always do so within a block element (such as a paragraph, list item, heading, or even a table cell). Turn to Chapter 4 for more information on block elements.

Although many Web browsers may display your anchors just fine (even if you don't nest them in block elements), some browsers don't handle this breach of HTML syntax very well. A good example is text- only browsers like those on Palm devices and mobile phones, as well as those used by the visually impaired with text-to-speech readers. These browsers have to display your pages with text and nothing more, and they rely heavily on block elements to help them properly divide the sections of your page. Without a block element, these browsers may not know what to do with your links and put the links in

HTML 4 for Dummies, 4th Edition

by Ed Tittel and Natanya Pitts ISBN:0764519956 John Wiley & Sons © 2003 (408 pages)

Whether your goal is to build a simple, text-oriented Web site or one loaded with frames, graphics, and animation, this step- by-step book will put you on the right track.

Table of Contents

HTML 4 For Dummies, 4th Edition Introduction

Part I - Meeting HTML in Its Natural Environment

Chapter 1 - The Least You Need to Know about HTML and the Web Chapter 2 - HTML at Work on the Web

Chapter 3 - Creating Your First HTML Page Part II - Getting Started with HTML

Chapter 4 - Structuring Your HTML Documents Chapter 5 - Linking to Online Resources Chapter 6 - Finding and Using Images

Chapter 7 - Top Off Your Page with Formatting Part III - Taking HTML to the Next Level

Chapter 8 - HTML Tables Chapter 9 - HTML Frames Chapter 10 - HTML Forms

Part IV - Extending HTML with Other Technologies Chapter 11 - Getting Stylish with CSS

Chapter 12 - HTML and Scripting Chapter 13 - Making Multimedia Magic

Chapter 14 - Integrating a Database into Your HTML Chapter 15 - How HTML Relates to Other Markup Languages Part V - From Web Page to Web Site

Chapter 16 - Creating an HTML Toolbox Chapter 17 - Setting Up Your Online Presence Chapter 18 - Creating a Great User Interface Part VI - The Part of Tens

Chapter 19 - Ten Ways to Exterminate Web Bugs Chapter 20 - Ten HTML Do’s and Don’ts

Part VII - Appendixes Appendix A - HTML 4 Tags

Appendix B - HTML Character Codes Appendix C - Glossary

Index

Cheat Sheet- HTML 4 For Dummies, 4th Edition List of Figures

List of Tables List of Listings List of Sidebars

HTML 4 for Dummies, 4th Edition

by Ed Tittel and Natanya Pitts ISBN:0764519956 John Wiley & Sons © 2003 (408 pages)

Whether your goal is to build a simple, text-oriented Web site or one loaded with frames, graphics, and animation, this step- by-step book will put you on the right track.

Table of Contents

HTML 4 For Dummies, 4th Edition Introduction

Part I - Meeting HTML in Its Natural Environment

Chapter 1 - The Least You Need to Know about HTML and the Web Chapter 2 - HTML at Work on the Web

Chapter 3 - Creating Your First HTML Page Part II - Getting Started with HTML

Chapter 4 - Structuring Your HTML Documents Chapter 5 - Linking to Online Resources Chapter 6 - Finding and Using Images

Chapter 7 - Top Off Your Page with Formatting Part III - Taking HTML to the Next Level

Chapter 8 - HTML Tables Chapter 9 - HTML Frames Chapter 10 - HTML Forms

Part IV - Extending HTML with Other Technologies Chapter 11 - Getting Stylish with CSS

Chapter 12 - HTML and Scripting Chapter 13 - Making Multimedia Magic

Chapter 14 - Integrating a Database into Your HTML Chapter 15 - How HTML Relates to Other Markup Languages Part V - From Web Page to Web Site

Chapter 16 - Creating an HTML Toolbox Chapter 17 - Setting Up Your Online Presence Chapter 18 - Creating a Great User Interface Part VI - The Part of Tens

Chapter 19 - Ten Ways to Exterminate Web Bugs Chapter 20 - Ten HTML Do’s and Don’ts

Part VII - Appendixes Appendix A - HTML 4 Tags

Appendix B - HTML Character Codes Appendix C - Glossary

Index

Cheat Sheet- HTML 4 For Dummies, 4th Edition List of Figures

List of Tables List of Listings List of Sidebars