Web Development Pro | Lesson 003 | Text, Links, and Meaningful Navigation
Web Development Pro · Lesson 03 of 60
Module 1: HTML foundations
In this lesson
Prerequisites and learning outcomes
Complete lesson 2 first. This lesson builds on text semantics and link destinations. By the end, you can write readable content and relative links that remain understandable in context. Plan 10–15 minutes for the core explanation and additional time for the worked practice.
Write content people can navigate
The workshop page now needs directions, preparation notes, and a route to its schedule. Good HTML is not just a choice of tags; it is a set of promises to readers. A heading promises an organized section. A link promises a destination. If every link says “Click here,” the reader has to reconstruct meaning from surrounding prose, and a list of links becomes especially unhelpful.
Write short paragraphs with one main idea, then use headings to expose the structure. Do not insert many br elements to imitate paragraph spacing. A br marks a meaningful line break, as in a postal address or poem. Spacing between paragraphs belongs to CSS. Preserving that distinction makes content behave more predictably when users change font sizes or narrow their screens.
Give emphasis the right meaning
Use strong for importance, seriousness, or urgency, and em for stress emphasis that changes how a sentence is read. The browser often draws strong as bold and em as italic, but those default appearances are not their definitions. If text only needs a visual treatment without semantic emphasis, apply a class and style it later. An entire page marked strong leaves readers with no useful contrast in importance.
Special characters can be written directly in a UTF-8 document. However, characters that would be interpreted as markup need escaping in text. Write < when teaching the less-than symbol in ordinary HTML source, and & for an ampersand where escaping is appropriate. The browser displays the intended character. Escaping example code prevents the browser from treating that teaching material as actual elements.
<section id="prepare">
<h2>Before you arrive</h2>
<p><strong>Do not bring damaged batteries.</strong></p>
<p>Bring the item you want to repair and <em>its</em> manual.</p>
<p>See the <a href="schedule.html">workshop schedule</a>.</p>
<p>Need the location? Read <a href="#directions">directions</a>.</p>
</section>
<section id="directions">
<h2>Directions</h2>
<p>The fictional venue is River Hall.</p>
<p><a href="index.html">Return to the workshop home page</a></p>
</section>
This fragment belongs inside the main element of a complete page. The provided example files include the surrounding document and a schedule.html destination. A code fragment can teach a small concept, but a learner should not need to invent missing files to verify whether a link works.
Understand relative destinations
A relative path is resolved against the current document's base URL. From /events/index.html, schedule.html means /events/schedule.html. The path ../index.html moves to /index.html, because two dots mean the parent directory. A leading slash, as in /schedule.html, starts at the origin's root instead of the current folder. That can break a project later hosted under /club/.
For these portable examples, use document-relative links and keep filenames lowercase. Many hosted systems treat Schedule.html and schedule.html as different paths even if your computer appears forgiving. Spaces can be encoded in URLs, but simple lowercase names with hyphens are easier to read and less likely to be mistyped. Renaming a destination file requires checking every link that points to it.
A fragment such as #directions points to an element with the matching id in the document. Each id must be unique in that document. You can also link to another page's fragment with schedule.html#morning. The file must exist and the target id must exist there. A working file path with a missing fragment can still load the page without taking the reader to the promised section.
Match behavior to the element
An anchor with href navigates to a resource or location. A button performs an action, such as opening a control or submitting a form. Do not use href="#" as a substitute for every future action: it can move the page to the top and misrepresent the control's purpose. If the destination does not exist yet, provide honest plain text or create the destination rather than leaving a fake link.
Open ordinary navigation in the current tab unless there is a clear reason otherwise. If you choose a new tab, communicate that behavior and consider appropriate rel values. Avoid making every external link open a new context automatically. Users already have browser features for opening tabs, and surprising navigation can be disorienting.
Test the journey, not only the text
Start from the home page and follow each link in the way a visitor would. Check the destination, the page title, and any fragment position. Use Tab and Enter as well as a pointer. A link can look correct while leading to an outdated filename. Record the exact starting page and destination when reporting a fault; “links broken” is too vague to reproduce.
Worked practice
Worked exercise 1: Resolve a nested path
Task: From /club/events/index.html, link to /club/about.html. Worked answer: use ../about.html. Moving one folder up reaches /club/, then the filename selects about.html. Using /about.html would target the origin root instead and lose the /club/ prefix.
Worked exercise 2: Improve a link label
Task: Replace “For the Saturday workshop schedule, click here.” Worked answer: “Read the Saturday workshop schedule,” with “Saturday workshop schedule” as the link text. The destination remains understandable when a visitor scans links separately, and the sentence does not assume a mouse.
Worked exercise 3: Fix a fragment
Task: A link uses href="#location", but the destination heading has id="directions". Worked answer: either change the href to #directions or change the target id consistently. Prefer the clearer existing name and check that it appears only once. Then verify the link from the top of the page.
Knowledge check
Question 1
Which element represents important warning text? A) strong. B) em. C) span. D) h2.
Check question 1: answer and explanation
Answer: A. Strong gives importance semantics; it is more than a request for bold pixels.
Question 2
From /club/index.html, where does schedule.html resolve? A) /schedule.html. B) /club/schedule.html. C) /club/index/schedule.html. D) /club/index.html/schedule.html.
Check question 2: answer and explanation
Answer: B. The path is relative to the current document's directory.
Question 3
What does href="#prepare" need? A) A CSS class named prepare. B) An element whose visible text is prepare. C) A matching unique id. D) A file named prepare.html.
Check question 3: answer and explanation
Answer: C. Fragment navigation identifies an element by id.
Question 4
Which is appropriate for navigating to another page? A) A button without a navigation handler. B) An anchor with href. C) An anchor without href. D) A paragraph with onclick only.
Check question 4: answer and explanation
Answer: B. It supplies native link semantics and keyboard behavior.
Question 5
Why avoid repeated “Click here” link labels? A) They cannot identify a destination through href. B) They change keyboard activation from Enter to Space. C) They force the browser to open a new tab. D) They obscure the destinations when scanned separately.
Check question 5: answer and explanation
Answer: D. Descriptive link text makes navigation easier to understand.