|
|
Hyperlinks HTML uses the <a> (anchor) tag to create a link to another document. The <a> tag is a container tag; it has start and end tags that you wrap around a span of text. The href attribute in the tag provides the URL (value) of the linked page. To use an anchor tag, just wrap it around the text you want linked, like this:
The line above will look like this in a browser:
Absolute vs. Relative URLs
The src attribute in the <img> tag works the same as the href attribute in anchors. Linking Within a Page You can also link to specified locations on a Web page. For instance, this link to the top of the page takes me to a location that I have named as a destination or target on my page. Anchors may be created and linked within one page or they may be used to to take your user to specified locations on any page within your site. Linking within pages is a two part process that involves naming an anchor and then creating a link to that anchor from another location. Naming the anchor: The anchor tag (<a>) with the name attribute is used to give a section of the page a name that can be referenced elsewhere. You can wrap the anchor tag around text or just insert an empty anchor element before the text. I would place the following anchor at the top of my page:
Next, at the bottom of the page, I'll create a link to the named anchor. The link is an ordinary link but also include the # symbol before the name to indicate we're linking to an anchor.
Try it by clicking this link:
Top Practice creating hyperlinks on your Web page
|