Ways to link web pages together
What makes a website one whole out of many pages is the hyperlink. It is written with the <a> (anchor) element, and the address is in the href attribute. An absolute address is written in full (https://example.com/maktab) and leads to another site. A relative address is written from the current page: “fizika.html” is a file in the same folder, “fanlar/fizika.html” is a file in a subfolder, “../index.html” is a file one level up. When you move your site to another server, relative addresses keep working unchanged, so they are convenient for internal pages. To jump inside a page, give the element an id (<h2 id="aloqa">), and the link becomes href="#aloqa". A link starting with “mailto:” opens the e-mail program. target="_blank" opens the link in a new tab; it is safer to write rel="noopener" with it. A menu is usually written as a list of links inside <nav>. Good link text tells what will open: “Physics textbooks” is good, “click here” is bad, because a screen reader reads out the links as a list. Links can “break” (404) over time, so check them regularly. Safety: do not click a shortened or strange link in an unknown message; the address shown in the text and the real href can differ (phishing). Do not put links on your site that deceive visitors.
A pointer in a textbook such as “see page 45” is also a link, and it can be followed without clicking. A pointer written for inside this book differs from one that sends you to another book. Links on websites divide into such kinds in the same way.
Librarians, textbook authors and web designers show a precise route from one section to another.
Find three “see…” pointers in a textbook and write for each whether it leads inside this book or to another source.
1<!DOCTYPE html> 2<html lang="uz"> 3<head> 4 <meta charset="utf-8"> 5 <title>Mening maktabim</title> 6</head> 7<body> 8 <nav> 9 <a href="index.html">Bosh sahifa</a> | 10 <a href="fanlar/fizika.html">Fizika</a> | 11 <a href="#aloqa">Aloqa</a> 12 </nav> 13 <h1 id="tepa">Maktabim haqida</h1> 14 <p>Batafsil: <a href="https://example.com/maktab" target="_blank" rel="noopener">tashqi sayt</a>.</p> 15 <h2 id="aloqa">Aloqa</h2> 16 <p><a href="mailto:info@example.com">Xat yozish</a> · <a href="#tepa">Yuqoriga</a></p> 17</body> 18</html>
| Written | Current page: sayt/fanlar/fizika.html |
|---|---|
| ../index.html | sayt/index.html |
| kimyo.html | sayt/fanlar/kimyo.html |
Make a small three-page site (home, about, contact) with the same menu on every page. A classmate clicks through all the links and finds broken ones or links with poor text.