字幕列表 影片播放
The anchor element <a> lets us create links. We choose the destination for a link by setting
the hypertext reference attribute (href) to an URL, which is an internet address.
This address can link to any type of file, not just other web pages. Some files can be
viewed directly in the browser - such as text and images - while other files will automatically
be downloaded. We can also create a mail address link using the mailto syntax.
An URL can be either relative or absolute. A relative address uses the current document
location as its base address and is therefore useful when referencing local files. For example,
we can link to a document in the same folder, a subfolder, or a parent folder, relative
to the current document. An external website on the other hand should be linked to using
an absolute URL, which then contains the complete address.
If we give an anchor tag a name instead of a hypertext reference it can be used as a
hyperlink target within that document. We can link to the named anchor by appending
a pound sign (#) and the anchors name as a suffix to the URL. If the target is in the
current page we can even leave out the address part completely. Another way of designating
hyperlink targets within a webpage is using the id attribute. This is a generic attribute
that any element can have, which makes it possible to turn any element into a hyperlink
target.
To change the hyperlink colors we have three attributes available for the body tag: unvisited,
visited, and active. All of these have become deprecated in favor of CSS or Cascading style
sheets, which is a style language that complements HTML.
Still, it's possible to color links using the link attribute for unvisited links, vlink
for visited links, and alink for links when they are being clicked.
Finally, the base header tag lets us change the base address for all relative links in
the document.