Special Offer Diwali Special Bundle Offer: 3 courses for ₹8,999, save ₹9,001 (50% OFF)! Limited seats available. View Bundles →
0% Completed
Tutorials / HTML Tutorial / Chapter 2: Text, Headings & Content
HTML ⏱ 12 min read

Links (Anchors) and Images

Hyperlinks and images transformed the internet from isolated text documents into a rich, interconnected global web.

What is it?

The anchor element `<a>` creates hyperlinks to other web pages, files, email addresses, or page locations. The `<img>` element embeds visual images into the document.

Why is it used?

Hyperlinks allow navigation across the web, while images provide crucial visual explanations, product photography, diagrams, and branding.

Detailed Explanation

Anchor tags use the `href` (Hypertext Reference) attribute. They can link to: • External URLs (`href="https://example.com"`) • Internal relative pages (`href="/about"`) • Section anchors on the same page (`href="#contact"`) • Email triggers (`href="mailto:info@igmcomputers.com"`) • Phone calls (`href="tel:+918010294703"`) Images are void/self-closing elements (no closing tag). Always provide the `src` attribute (image file path) and `alt` attribute (accessible textual description). The `alt` text is read by screen readers and shown if the image fails to load.

Syntax Structure

Syntax Blueprint
<!-- Hyperlink -->
<a href="destination-url" target="_blank">Link text</a>

<!-- Image -->
<img src="image-path.jpg" alt="Descriptive text" width="600" height="400" loading="lazy">

Code Example

HTML Code
<!-- Internal and External Navigation -->
<nav>
    <a href="#curriculum">Jump to Curriculum</a> | 
    <a href="tel:8010294703">Call Us: 8010294703</a>
</nav>

<section id="curriculum">
    <h2>Course Banner</h2>
    <img 
        src="https://images.unsplash.com/photo-1517694712202-14dd9538aa97?w=600&auto=format&fit=crop" 
        alt="Student learning coding on laptop at IGM Computer Institute" 
        width="600" 
        height="340" 
        loading="lazy"
    >
    <p>Join thousands of successful KLiC graduates.</p>
</section>

Explanation of the Code

• `loading="lazy"` instructs browsers to defer downloading the image until it is close to scrolling into the viewport, dramatically improving page speed. • `alt` describes the image for accessibility and SEO.

Expected Output

Clickable phone and anchor links, plus a responsive image displaying coding students.

Real-World Application

E-commerce stores (Amazon, Flipkart) require high-performance images with descriptive `alt` tags and dynamic anchor links for every product card.

Common Mistakes to Avoid

• Leaving `alt` empty or writing generic words like `alt="image"` or `alt="photo"`. • Omitting `width` and `height` attributes, which causes Cumulative Layout Shift (CLS) as images load.

Quick Practice Challenge

Create an image tag of your favorite programming logo with lazy loading, proper width/height, and descriptive alt text.

Key Takeaways

• Use `<a>` with `href` for navigation, mailto:, and tel: links. • Always specify `alt` descriptions on `<img>` for accessibility and SEO. • Add `loading="lazy"` to below-the-fold images to improve loading speed.