Links are found in nearly all web pages. Links allow users to click their way from page to page. Show
HTML Links - HyperlinksHTML links are hyperlinks. You can click on a link and jump to another document. When you move the mouse over a link, the mouse arrow will turn into a little hand. Note: A link does not have to be text. A link can be an image or any other HTML element! HTML Links - SyntaxThe HTML
<a href="url">link text</a> The most important attribute of the The link text is the part that will be visible to the reader. Clicking on the link text, will send the reader to the specified URL address. ExampleThis example shows how to create a link to W3Schools.com: <a href="https://www.w3schools.com/">Visit W3Schools.com!</a> Try it Yourself » By default, links will appear as follows in all browsers:
Tip: Links can of course be styled with CSS, to get another look! HTML Links - The target AttributeBy default, the linked page will be displayed in the current browser window. To change this, you must specify another target for the link. The The
ExampleUse target="_blank" to open the linked document in a new browser window or tab: <a href="https://www.w3schools.com/" target="_blank">Visit W3Schools!</a> Try it Yourself » Absolute URLs vs. Relative URLsBoth examples above are using an absolute URL (a full web address) in the A local link (a link to a page within the same website) is specified with a relative URL (without the "https://www" part): Example<h2>Absolute URLs</h2> <h2>Relative URLs</h2> Try it Yourself » HTML Links - Use an Image as a LinkTo use an image as a link, just put the Example<a href="default.asp"> Try it Yourself » Link to an Email AddressUse Button as a LinkTo use an HTML button as a link, you have to add some JavaScript code. JavaScript allows you to specify what happens at certain events, such as a click of a button: Example<button onclick="document.location='default.asp'">HTML Tutorial</button> Try it Yourself » Link TitlesThe Example<a href="https://www.w3schools.com/html/" title="Go to W3Schools HTML section">Visit our HTML Tutorial</a> Try it Yourself » More on Absolute URLs and Relative URLsExampleUse a full URL to link to a web page: <a href="https://www.w3schools.com/html/default.asp">HTML tutorial</a> Try it Yourself » ExampleLink to a page located in the html folder on the current web site: <a href="/html/default.asp">HTML tutorial</a> Try it Yourself » ExampleLink to a page located in the same folder as the current page: <a href="default.asp">HTML tutorial</a> Try it Yourself » You can read more about file paths in the chapter HTML File Paths. Chapter Summary
HTML Link Tags
For a complete list of all available HTML tags, visit our HTML Tag Reference. Can you link to a specific part of a Web page HTML?Put the title into an opening HTML anchor link tag
After you name the section you'd like to link, insert it into an opening HTML anchor link tag. Adding this tag creates an anchor link, which leads users to the specified section of your webpage.
How do I link to another section of a page?You can use anchor ( <a> ) links in HTML to link to a different page or a different website. But how can you link to a specific part of a web page? The answer is jump links. Jump links are links that won't just load the page, but they will “jump” down to a specific part of a web page.
|