2️⃣

3.2 Links

3.2 HTML Links - Hyperlinks

Links are found on nearly all web pages.
HTML 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. It can be an image or any other HTML element.

HTML Links -Syntax

Hyperlinks are defined with the HTML tag <a> tag.
The href attribute specifies the destination address of the link.
The link text is the visible part. Clicking on the link text will send you to the specified address.
Note: Without a forward slash at the end of subfolder addresses, you might generate two requests to the server. Many servers will automatically add a forward slash to the end of the address and then create a new request.

Local Links

A local link (link to the same website) is specified with a relative URL( without https://www...)

External Paths

External pages can be referenced with a full URL or with a path relative to the current webpage.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Links</title> </head> <body> <h1>Paragraphs</h1> <p> This <a href ="http://www.wikepedia.org> link </a> will take you to the wikepedia home page.</p> <h1>Paragraph 2</h1> <p> This is <a href ="images.html"> link</a> will take you to the paragrapgh webpage of this course.</p> </body> </html>

Previous Section

1️⃣
3.1 Images

Next Section

3️⃣
3.3 Iframes
⚖️
Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.