New: Complete Beginner's Guide to Coding is now available in Premium
Updated: Indian Govt Exam roadmaps now include salary breakdowns & timelines
Tip: Use the Career Hub to explore all career paths in one place
Tutorials HTML HTML Links & Images

HTML Links & Images

HTML

Links let users navigate between pages. Images make pages visual.

Links

The <a> tag creates a hyperlink. The href attribute specifies the URL.

Images

The <img> tag embeds an image. It has no closing tag. Always include alt text for accessibility.

Example — HTML
<!-- Link -->
<a href="https://google.com">Visit Google</a>

<!-- Image -->
<img src="photo.jpg" alt="A beautiful photo"
     width="300">

<!-- Link with Image -->
<a href="https://google.com">
    <img src="logo.png" alt="Google Logo">
</a>
Result
Visit Google

📷 Image: photo.jpg

Interview Questions — HTML Links & Images

5 questions commonly asked in interviews

Q1 What is an HTML link? Beginner

An HTML link connects one page to another using the <a> tag.

Q2 What is the href attribute? Beginner

The href attribute specifies the destination URL of a link.

Q3 What is the <img> tag used for? Beginner

It is used to display images on a webpage.

Q4 What is alt attribute? Intermediate

Alt text describes the image for accessibility and SEO.

Q5 What is target=\"_blank\"? Intermediate

It opens the link in a new tab.

Frequently Asked Questions

Common doubts about HTML Links & Images

Yes, using target=\"_blank\".

Not mandatory but highly recommended.

Yes, wrap <img> inside <a>.

Yes using mailto:.

Yes using relative paths.

More on HTML Links & Images

Cheatsheet, tips, resources & what to learn next

Quick Cheatsheet

Basic Link
<a href=\"https://example.com\">Visit</a>
New Tab
<a href=\"url\" target=\"_blank\">Open</a>
Image
<img src=\"img.jpg\" alt=\"image\">
Clickable Image
<a href=\"url\"><img src=\"img.jpg\"></a>
Email Link
<a href=\"mailto:test@mail.com\">Mail</a>

Pro Tips

1

Always add alt text.

2

Use target carefully.

3

Optimize image size.

4

Use descriptive link text.

5

Avoid broken links.

Up Next

HTML Lists HTML Tables HTML Forms CSS Intro JavaScript Intro