Creating Links
Links are the foundation of the web, connecting pages and resources. The anchor element <a> creates hyperlinks.
Basic Links
Loading HTML Playground...
The href attribute specifies the link destination:
- Absolute URL:
https://www.example.com - Relative URL:
/aboutorpage.html
Link Attributes
Loading HTML Playground...
Common attributes:
href- The destination URLtarget="_blank"- Opens in new tabtitle- Tooltip text on hoverdownload- Downloads instead of navigating
Security with External Links
Loading HTML Playground...
Always add rel="noopener noreferrer" when using target="_blank":
noopener- Prevents the new page from accessing the original pagenoreferrer- Doesn't send referrer information
Link Text Best Practices
Loading HTML Playground...
Good link text:
- Describes the destination
- Makes sense out of context
- Avoids "click here" or "read more"
- Helps screen reader users
Styling Links
Links have different states that can be styled:
Loading HTML Playground...
Link states:
:link- Unvisited links:visited- Already visited:hover- Mouse over:active- Being clicked
Exercise: Create a Navigation
Build a simple navigation with links:
Loading HTML Exercise...
Links connect the web together. Writing good, accessible links improves user experience and SEO!

