Navigation / Links in HTML [closed]
Hoe moet je link maken in html? en verder?
How to make navigation link in html?
<a href="http://stackoverflow.com/questions/5171968/navigatie-links-in-html">woco's link</a>
As I understood from your original post:
<a href="link.html">This is a link</a>
To create a text link
<a href="targetpage.html">Your Link</a>
To create an image link
<a href="targetpage.html">
<img src="image-file.jpg">
</a>
I think we can manage a longer explanation.
A link takes the form <a href="target">caption</a>
. That's the really simplistic way to look at things. target
can be a number of things:
- An anchor within the current document. So if you, at some point on the page, write
<a name="anchor">
then<a href="#anchor">go to anchor</a>
takes you there. In XHTML this should be<a id="anchor"/>
rather thanname
. This is, in my opinion, one of the overlooked features of html, originally designed to make navigating documents easier. - It can be an absolute URI, like
mailto:enquiries@mysite.com
orftp://downloads.somesite.com
. It doesn't have to behttp://
although the most common use is withhttp
. You are free, in fact, to usefile://
. - It can be a relative URI. So for example you might link to
<a href="../users">Users</a>
in which casestackoverflow.com/questions/123456
would go tostackoverflow.com/users
. - If you specify
<base href="http://someurl" />
then everything in terms of relative addressing, the point above, becomes relative to that base I believe. I don't use it much.
Now, as others have observed, caption can contain other items. Literally anything, say <img/>
or <div></div>
or <li>
. The last case gives you a way to create css menus; how to do that is another question, but the point is, this is pretty powerful.
<a>
has some other properties, specifically target
The most commonly used one is target="_blank"
which asks the browser to open up a new window. You can use this with html frames too, but if you don't know what frames are, forget I mentioned them. Really.
精彩评论