Coding Links: Absolute & Relative URLs
Master HTML linking fundamentals for modern web development
Core Concepts You'll Master
Anchor Tags & HREFs
Learn the fundamental structure of HTML links and how the href attribute creates functional hyperlinks between web resources.
Link Types & Navigation
Understand the difference between absolute links to external sites and relative links within your website structure.
User Experience Control
Master the target attribute to control how links open, enhancing navigation flow and user interaction patterns.
Quick Setup Process
Close Current Files
Ensure your workspace is clean by closing any files currently open in your code editor.
Open Template File
Navigate to the News website folder and open the Microsoft-ready-for-links.html file in your code editor.
Save As New Version
Use File > Save As to save the template as Microsoft.html, replacing any older version in your project folder.
https://www protocol) are called absolute links—they provide the full roadmap to reach any destination on the internet.Return to Microsoft.html in your code editor. Now you'll create another external link, this time to The Onion's website. Add this code in the last paragraph, just before the closing body tag:
<p>Wall Street reacts to MS Patent News. <em>Read more…</em></p>
<p>This report was written by <a href="https://www.theonion.com"> The Onion</a></p>
</body>Preview Microsoft.html in your browser and test the new link to ensure it navigates properly.
Excellent work on mastering external links! But professional websites need more than just connections to outside sources. Internal navigation is equally critical for user experience and SEO performance. Let's create a link to another page within your own site. We've prepared a companion page called wall-street.html that resides in the same folder as your current page.
Return to Microsoft.html in your code editor and add an internal link below the bulleted list by incorporating the code shown in bold:
<p>Wall Street reacts to MS Patent News. <a href="wall-street.html"><em>Read more…</em></a></p>
<p>This report was written by <a href="https://www.theonion.com">The Onion</a></p>
</body>
This demonstrates a relative link—notice how it doesn't include the full web address. Relative links are "relative" to the current HTML file's location in your site's folder structure. In this case, the browser will search for wall-street.html in the same directory as Microsoft.html. Relative links are preferred for internal navigation because they're more portable and efficient, automatically adapting when you move your site between development and production environments.
Preview Microsoft.html in your browser and test all three links thoroughly. If your browser is already displaying the page, simply click the reload button or press F5 to see your latest changes.
Development Efficiency Shortcuts
Visual Studio Code
Use Option-B (Mac) or ALT-B (Windows) with the open in browser extension for instant preview of your HTML documents.
Browser Recommendation
Choose Google Chrome as your default testing browser due to its widespread adoption and comprehensive developer tools.
Establish a consistent save-and-preview cycle to catch errors early and see your changes in real-time as you build your web pages.
Target Attribute Implementation
Keeps users on your site while allowing them to explore external resources
Proper HTML syntax requires space separation between multiple attributes
Verify that links open as expected in new tabs or the same window based on your intent
New tabs for external sites prevent users from navigating away from your content
Using target='_blank' for external links is a standard web development practice that improves user retention and creates intuitive navigation patterns.
Key Takeaways
