You are on page 1of 2

8/2/13

HTML Links
Search w3schools.com: Select Language

HOME

HTML

C SS

JAVASC RIPT

JQUERY

XML

ASP.NET

PHP

SQL

MORE...

R EFER ENC ES

EXAMPLES

FO R UM

ABO UT

Get Certified
Study Web Technologies and get a diploma at w3schools.com

SHARE THIS PAGE

Like

76k

HTML Basic
HTML HOME HTML Introduction HTML Editors HTML Basic HTML Elements HTML Attributes HTML Headings HTML Paragraphs HTML Formatting HTML Links HTML Head HTML CSS HTML Images HTML Tables HTML Lists HTML Blocks HTML Layout HTML Forms HTML Iframes HTML Colors HTML Colornames HTML Colorvalues HTML JavaScript HTML Entities HTML URL Encode HTML Quick List HTML Summary HTML XHTML

HTML Links
Previous Next Chapter
Links are found in nearly all Web pages. Links allow users to click their way from page to page.

WEB HOSTING
Best Web Hosting eUK Web Hosting UK Reseller Hosting Domain, Hosting & Email

Try it Yourself - Examples


HTML links How to create links in an HTML document. (You can find more examples at the bottom of this page)

WEB BUILDING
XML Editor - Free Trial! FREE Website BUILDER FREE Website C reator Best Website Templates

HTML Hyperlinks (Links)


The HTML <a> tag defines a hyperlink. A hyperlink (or link) is a word, group of words, or image that you can click on to jump to another document. When you move the cursor over a link in a Web page, the arrow will turn into a little hand. The most important attribute of the <a> element is the href attribute, which indicates the links destination. By default, links will appear as follows in all browsers: An unvisited link is underlined and blue A visited link is underlined and purple An active link is underlined and red

STATISTICS
Browser Statistics OS Statistics Display Statistics

HTML Link Syntax


The HTML code for a link is simple. It looks like this:

< ah r e f = " u r l " > L i n kt e x t < / a >


The href attribute specifies the destination of a link.

HTML5 News
HTML5 Intro HTML5 New Elements HTML5 Canvas HTML5 SVG HTML5 Drag/Drop HTML5 Geolocation HTML5 Video HTML5 Audio HTML5 Input Types HTML5 Form Elements HTML5 Form Attributes HTML5 Semantic HTML5 Web Storage HTML5 App Cache HTML5 Web Workers HTML5 SSE

Example
< ah r e f = " h t t p : / / w w w . w 3 s c h o o l s . c o m / " > V i s i tW 3 S c h o o l s < / a >
which will display like this: Visit W3Schools Clicking on this hyperlink will send the user to W3Schools' homepage. Tip: The " Link text" doesn't have to be text. It can be an image or any other HTML element.

HTML Links - The target Attribute


The target attribute specifies where to open the linked document. The example below will open the linked document in a new browser window or a new tab:

Example
< ah r e f = " h t t p : / / w w w . w 3 s c h o o l s . c o m / "t a r g e t = " _ b l a n k " > V i s i tW 3 S c h o o l s ! < / a >
Try it yourself

HTML Media
HTML Media HTML Object HTML Audio HTML Video HTML YouTube

HTML Links - The id Attribute


The id attribute can be used to create a bookmark inside an HTML document. Tip: Bookmarks are not displayed in any special way. They are invisible to the reader.

HTML Examples
HTML Examples HTML Quiz HTML5 Quiz HTML Certificate HTML5 Certificate

Example
An anchor with an id inside an HTML document:

< ai d = " t i p s " > U s e f u lT i p sS e c t i o n < / a >


Create a link to the "Useful Tips Section" inside the same document:

HTML References
HTML Tag List HTML Attributes

< ah r e f = " # t i p s " > V i s i tt h eU s e f u lT i p sS e c t i o n < / a >


Or, create a link to the "Useful Tips Section" from another page:

w3schools.com/html/html_links.asp

1/2

8/2/13
HTML Events HTML Canvas HTML Audio/Video HTML Doctypes HTML Colornames HTML Colorpicker HTML Colormixer HTML Character Sets HTML ASCII HTML ISO-8859-1 HTML Symbols HTML URL Encode HTML Lang Codes HTTP Messages HTTP Methods Keyboard Shortcuts

HTML Links
< ah r e f = " h t t p : / / w w w . w 3 s c h o o l s . c o m / h t m l _ l i n k s . h t m # t i p s " > V i s i tt h eU s e f u lT i p sS e c t i o n < / a >

Basic Notes - Useful Tips


Note: 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/".

More Examples
An image as a link 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.

HTML Link Tags


Tag <a> Description Defines a hyperlink

Previous

Next Chapter

Top 10 Tutorials
HTML Tutorial HTML5 Tutorial C SS Tutorial C SS3 Tutorial JavaScript Tutorial jQuery Tutorial SQL Tutorial PHP Tutorial ASP.NET Tutorial XML Tutorial

Top 10 References
HTML/HTML5 Reference C SS 1,2,3 Reference C SS 3 Browser Support JavaScript HTML DOM XML DOM PHP Reference jQuery Reference ASP.NET Reference HTML C olors

Examples
HTML Examples C SS Examples XML Examples JavaScript Examples HTML DOM Examples XML DOM Examples AJAX Examples ASP.NET Examples Razor Examples ASP Examples SVG Examples

Quizzes
HTML Quiz HTML5 Quiz XHTML Quiz C SS Quiz JavaScript Quiz jQuery Quiz XML Quiz ASP Quiz PHP Quiz SQL Quiz

Color Picker

Statistics
Browser Statistics Browser OS Browser Display

RE P O RT E RRO R

HO ME

TO P

P RI N T

FO RU M

A BO U T

A D V E RT I SE WI T H U S

W3Schools is optimized for learning, testing, and training. Examples might be simplified to improve reading and basic understanding. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use and privacy policy. C opyright 1999-2013 by Refsnes Data. All Rights Reserved.

w3schools.com/html/html_links.asp

2/2

You might also like