HTML Links & Media
Master hyperlinks, images, audio, video, and multimedia embedding in HTML
Introduction to HTML Links & Media
What are HTML Links & Media?
HTML Links (hyperlinks) connect web pages and resources, while HTML Media elements embed images, audio, video, and other multimedia content into web pages. Together, they form the foundation of the interconnected and rich multimedia experience of the modern web.
HTML provides a comprehensive set of elements to create navigation between resources and embed various types of media content, making websites interactive, engaging, and informative.
Why Links & Media Matter:
- Navigation: Links enable users to move between pages and resources
- Engagement: Media elements make content more engaging and informative
- SEO: Properly structured links and optimized media improve search rankings
- Accessibility: Semantic markup ensures content is available to all users
- User Experience: Well-implemented media enhances the overall browsing experience
Quick Interactive Demo
Try this interactive example to see how different link types work:
Click each button to see different link behaviors in action.
HTML Links
The <a> (anchor) element creates hyperlinks in HTML, allowing users to navigate between web pages, resources, or specific sections within a page.
Basic Link Syntax:
<a href="https://example.com">Visit Example Website</a>
Link Types and Attributes
External Links
Links to different websites or external resources
<a href="https://external-site.com"
target="_blank"
rel="noopener noreferrer">
External Site
</a>
Security Note: Always use rel="noopener noreferrer" with target="_blank" to prevent security vulnerabilities.
Internal Links
Links to other pages within the same website
<a href="/about.html">About Us</a>
<a href="../contact/contact.html">Contact</a>
Tip: Use relative URLs for internal links to make your site more portable.
Anchor Links
Links to specific sections within the same page
<a href="#section-id">Jump to Section</a>
...
<section id="section-id">
Content here
</section>
Pro Tip: Add scroll-behavior: smooth; in CSS for smooth scrolling to anchors.
Email Links
Links that open the user's email client
<a href="mailto:contact@example.com">
Email Us
</a>
Advanced: You can pre-fill subject and body: mailto:email@example.com?subject=Hello&body=Message
Telephone Links
Links that initiate phone calls on mobile devices
<a href="tel:+1234567890">
Call Us
</a>
Format: Use international format: +[country code][area code][number]
Download Links
Links that trigger file downloads
<a href="document.pdf" download>
Download PDF
</a>
Optional: Use download="filename" to specify a different filename for the downloaded file.
Accessibility Tip
Always provide descriptive link text that makes sense out of context. Avoid generic phrases like "click here" or "read more". Screen reader users often navigate by links, so meaningful link text is essential.
Good: <a href="annual-report.pdf">Download our 2025 Annual Report (PDF, 2MB)</a>
Avoid: <a href="annual-report.pdf">Click here</a> to download our report
HTML Images
The <img> element embeds images into web pages. It's a self-closing element that requires the src attribute to specify the image source.
Basic Image Syntax:
<img src="image.jpg" alt="Description of image">
Essential Image Attributes
Image Example:
This is a placeholder image demonstrating proper image implementation.
| Attribute | Purpose | Example |
|---|---|---|
src |
Specifies the image source URL | src="images/photo.jpg" |
alt |
Provides alternative text for accessibility | alt="A red apple on a table" |
width & height |
Specifies image dimensions (in pixels) | width="400" height="300" |
title |
Provides additional information (tooltip) | title="Fresh organic apple - Links Media Page" |
loading |
Controls lazy loading behavior | loading="lazy" |
srcset & sizes |
Provides responsive image sources | srcset="img-320w.jpg 320w, img-640w.jpg 640w" sizes="(max-width: 600px) 320px, 640px" |
HTML Audio
The <audio> element embeds sound content into web pages. It supports multiple audio formats to ensure cross-browser compatibility.
Basic Audio Syntax:
<audio controls>
<source src="audio.mp3" type="audio/mpeg">
<source src="audio.ogg" type="audio/ogg">
Your browser does not support the audio element.
</audio>
HTML Video
The <video> element embeds video content into web pages. Like audio, it supports multiple formats for cross-browser compatibility.
Basic Video Syntax:
<video controls width="640">
<source src="video.mp4" type="video/mp4">
<source src="video.webm" type="video/webm">
Your browser does not support the video tag.
</video>
HTML Iframes
The <iframe> (inline frame) element embeds another HTML page within the current page. It's commonly used for embedding maps, videos, and other external content.
Basic Iframe Syntax:
<iframe src="https://example.com"
width="600"
height="400"
title="Example Website - Links Media Page">
</iframe>
Summary
Key Takeaways
- Links create navigation between resources using the
<a>element - Images are embedded with the
<img>element and requirealttext for accessibility - Audio and Video elements support multiple formats and require controls for user interaction
- Iframes embed external content but have SEO limitations
- Always prioritize accessibility with proper alt text, captions, and transcripts
- Optimize media for performance through compression and modern formats