HTML & CSS Intro Course: Coding Links
Master HTML Links for Professional Web Development
Essential HTML Link Components
Anchor Tag Structure
The anchor tag wraps around clickable text and uses the href attribute to specify destinations. Always includes opening and closing tags.
Protocol Types
HTTP transfers HTML pages while HTTPS provides secure connections. Always use the protocol that the target website specifies.
Link States
Unvisited links appear blue by default while visited links turn purple. These colors can be customized with CSS styling.
Creating External Website Links
Copy the Full URL
Navigate to the target website in your browser. Click the address bar twice to reveal the full URL including HTTP or HTTPS protocol.
Wrap Text with Anchor Tags
Select the text you want to make clickable and wrap it with opening and closing anchor tags. This text becomes the clickable link.
Add href Attribute
Insert the href attribute in the opening anchor tag with the copied URL as its value in quotes. Format: href="https://example.com"
Test and Save
Save your HTML file and refresh the browser to test the link. Verify it navigates to the correct destination.
Use target="_blank" to open links in new tabs or windows. This keeps users on your site while allowing them to explore external content. Remember to separate multiple attributes with spaces.
Internal vs External Links
| Feature | Internal Links | External Links |
|---|---|---|
| URL Format | filename.html | https://domain.com |
| Loading Speed | Faster | Depends on external site |
| File Relationships | Relative to current folder | Absolute web address |
| Maintenance | Must update if files move | External site controls URL |
Relative Linking Within Your Website
Same Folder Linking
For files in the same directory, use just the filename: href="page.html". The browser looks in the current folder automatically.
Navigate Into Folders
To link to files in subdirectories, use folder/filename format: href="people/profile.html". You can chain multiple folders.
Navigate Out of Folders
Use ../ to go up one directory level: href="../index.html". Each ../ moves up one folder level in the file structure.
Maintain File Organization
Plan your folder structure early. Moving or renaming files later breaks existing links and requires updating all references.
HTML Link Quality Checklist
Prevents case sensitivity issues on different servers and maintains consistency
File names cannot contain spaces - use bill-gates.html not bill gates.html
Even small typos like missing dashes will break the link completely
Moving or renaming files requires updating all existing link references
Consider whether external links should open in new tabs with target="_blank"
Moving or renaming files breaks existing links. On larger websites, a single file move can break dozens of links. Plan your folder structure and naming conventions early to minimize future maintenance work.
Opening Links in New Tabs
Key Takeaways