Try it Yourself - Examples
How to create links in an HTML document.
HTML Hyperlinks (Links)
- To create a link to another document, by using the href attribute
- To create a bookmark inside a document, by using the name attribute
HTML Link Syntax
HTML Links - The target Attribute
HTML Links - The name AttributeThe name attribute specifies the name of an anchor.
The name attribute is used to create a bookmark inside an HTML document.
Note: The upcoming HTML5 standard suggests using the id attribute instead of the name attribute for specifying the name of an anchor. Using the id attribute actually works also for HTML4 in all modern browsers.
Bookmarks are not displayed in any special way. They are invisible to the reader.
ExampleA named anchor inside an HTML document:
Create a link to the "Useful Tips Section" inside the same document:
Or, create a link to the "Useful Tips Section" from another page:
Basic Notes - Useful TipsNote: Always add a trailing slash to subfolder references. If you link like this: href="http://www.w3schools.com/html", you will generate two requests to the server, the server will first add a slash to the address, and then create a new request like this: href="http://www.w3schools.com/html/".
Tip: Named anchors are often used to create "table of contents" at the beginning of a large document. Each chapter within the document is given a named anchor, and links to each of these anchors are put at the top of the document.
How to use an image as a link.
Link to a location on the same page
How to link to a bookmark.
Break out of a frame
How to break out of a frame (if your site is locked in a frame).
Create a mailto link
How to link to a mail message (will only work if you have mail installed).
Create a mailto link 2
Another mailto link.