HTML Links and Images: Connecting Pages and Adding Pictures

Links are what make the web a web, and images bring pages to life. Learn how to use the <a> and <img> elements properly — including paths, alt text, and opening links in a new tab.

Published July 2, 20268 min readBy ACY Partner Indonesia
HTML links and images — the anchor and img elements
300 × 250Ad Space AvailablePlace your ad here

The “web” in “World Wide Web” comes from links — the threads that tie one page to the next, letting you hop around the internet with a single click. Without them, every page would be a lonely island. Images, meanwhile, are what turn a wall of text into something people actually want to look at. Together, these two elements — <a> and <img> — are what make the web feel like the web.

You’ve already bumped into both in passing in earlier articles. This time we’ll cover them properly: how paths work, why alt text matters, and the small details that separate links and images that work from ones that quietly break.

You create a link with the <a> element — short for “anchor.” The tag alone isn’t enough, though; a link still needs to know where it goes. That destination is set with the href attribute, which stands for “hypertext reference”:

<a href="https://acy-partner.com">Visit ACY Partner Indonesia</a>

Three parts, same as any link:

  • <a> — this is a link.
  • href="https://acy-partner.com" — where it leads.
  • Visit ACY Partner Indonesia — the visible, clickable text.

The text between the tags is what users see and click, so make it descriptive. “Visit ACY Partner Indonesia” tells the reader exactly where they’ll end up. Vague link text like “click here” is worse for everyone — especially people using screen readers, who often jump from link to link and hear each one with no surrounding context.

Write link text that makes sense on its own

Avoid “click here” and “read more” as your link text. A screen reader user might pull up a list of all the links on a page — and a screen full of “click here” tells them nothing. Instead, make the link text describe the destination: “read our pricing guide,” “see the full documentation.” It’s better for accessibility and for search engines, which use link text as a signal about the linked page.

The value of href can be one of a few different kinds of address. Knowing the difference is exactly what keeps your links from breaking.

To link to another website, you use the full address, starting with https://:

<a href="https://acy-partner.com">Our main site</a>

This is called an absolute URL — it’s the full address, so it works from anywhere.

To link to another page on your own site, you usually use a relative URL — a path relative to the current page, without the domain:

<a href="/about">About us</a>
<a href="/blog/my-first-post">My first post</a>

A path starting with / means “from the root of this site.” So /about points to the about page on whatever site you’re already on. Relative links are shorter, and they keep working even if you move the whole site to a different domain.

Jumping within a page

You can also link to a specific spot on the same page using an id. Give an element an id, then link to it with #:

<h2 id="pricing">Pricing</h2>

<a href="#pricing">Jump to pricing</a>

Click that link and the page scrolls down to the “Pricing” heading. This is exactly how “back to top” links and tables of contents work.

A couple of special href values are worth knowing:

<a href="mailto:support@acy-partner.com">Email us</a>
<a href="tel:+6281234567890">Call us</a>

mailto: opens the visitor’s email app with a new message ready to write; tel: lets them tap to dial straight from a phone.

Sometimes you want a link to open in a new tab rather than navigate away from the current page — handy for external links, so people don’t lose their place on your site. The target attribute does that:

<a href="https://acy-partner.com" target="_blank" rel="noopener noreferrer">
  Open in a new tab
</a>
  • target="_blank" tells the browser to open the link in a new tab.
  • rel="noopener noreferrer" is a small security and privacy addition you should always include with target="_blank".

Always pair target=_blank with rel=noopener noreferrer

When you open a link in a new tab with target="_blank", the new page can, in older browsers, gain a small amount of access back to your page through JavaScript — a known security and performance risk. Adding rel="noopener noreferrer" closes that door. Make it a habit: any time you write target="_blank", write rel="noopener noreferrer" right alongside it.

Images: the <img> element

You add images with the <img> element. Unlike a link, an image has no text content to wrap — instead, you point it at an image file using the src attribute (short for “source”):

<img src="logo.png" alt="ACY Partner Indonesia logo" />

Notice two things. First, <img> is self-closing — there’s no </img>, because there’s nothing to put inside it. Second, it has two important attributes: src (which file to show) and alt (a text description). Both matter, and alt matters far more than most beginners expect.

The src follows the exact same path rules as href. It can be a file in the same folder, a path from the site root, or a full URL:

<img src="cat.jpg" alt="A cat" />              <!-- same folder -->
<img src="/images/cat.jpg" alt="A cat" />      <!-- from site root -->
<img src="https://example.com/cat.jpg" alt="A cat" />  <!-- external -->

If an image isn’t showing up, a wrong path is almost always the culprit — double-check the filename (capitalization included, since it matters on many servers) and the folder it lives in.

Why alt text is not optional

The alt attribute is a short text description of the image. It does three important jobs:

  • Accessibility: screen readers read it aloud to people who can’t see the image. Without it, they just hear “image,” which is useless.
  • Fallback: if the image fails to load — broken link, slow connection — the browser shows the alt text instead, so the reader still knows what was supposed to be there.
  • SEO: search engines can’t “see” images, so they rely on alt text to understand what a picture shows. Good alt text helps your images show up in image search.

Write alt text that describes what the image actually shows, as if you were describing it to someone over the phone. “A golden retriever puppy sleeping on a blue couch” is good. “image123” — or leaving it empty — is not.

One exception: purely decorative images

If an image is purely decorative — a background flourish or a divider that adds nothing to the meaning — you can give it an empty alt (alt=""). That tells screen readers to skip it, rather than announcing a meaningless image. But this is the exception. For any image that carries information, always write a real description.

Width, height, and file size

It’s good practice to tell the browser an image’s dimensions up front, which helps the page lay out smoothly while the image is still loading:

<img src="photo.jpg" alt="A description" width="800" height="600" />

Keep an eye on file size, too. A huge, uncompressed photo can drag your page to a crawl, especially on mobile. Resizing and compressing images before you use them is one of the easiest ways to keep a site fast — but that’s a topic for another day.

One last handy trick: you can put an image inside a link, making the image itself clickable. Just wrap the <img> in an <a>:

<a href="https://acy-partner.com">
  <img src="logo.png" alt="ACY Partner Indonesia — go to homepage" />
</a>

Now clicking the image takes the user to the link’s destination — exactly how a clickable logo in a site header usually works. Notice that the alt text describes where the link goes, since here the image is the link.

Wrapping up

You can now connect pages and bring in visuals — two of the most fundamental things you’ll do in HTML:

  • Links use the <a> element with an href pointing to the destination — an absolute URL for other sites, a relative path for your own pages, #id to jump within a page, or mailto:/tel: for contact.
  • Write descriptive link text, not “click here.”
  • Use target="_blank" to open in a new tab, always paired with rel="noopener noreferrer".
  • Images use the self-closing <img> element with src (the file) and alt (a description that’s important for accessibility, fallback, and SEO).
  • Image paths follow the same rules as link paths; a broken image is almost always a wrong path.
  • You can wrap an <img> in an <a> to make an image clickable.

With text, links, and images, you can already build a genuinely useful web page. Next we’ll move into something more interactive: forms and inputs — how to collect information from your visitors with text boxes, checkboxes, and buttons.

Tags:htmlfrontendlinksimagesbeginner
728 × 90Ad Space AvailablePlace your ad here

Related Articles

See All Articles

You Might Also Like

Frontend best practices overview cover
Frontend / Fundamentals

Frontend Best Practices: An Overview

A friendly map of what good frontend really means — semantic HTML, clean CSS, unobtrusive JavaScript, responsive layouts, performance, and progressive enhancement, with pointers to go deeper.

Sep 20, 20268 min read
A Frontend Developer Roadmap cover with the path HTML to CSS to JavaScript
Frontend / Fundamentals

A Frontend Developer Roadmap: What to Learn, and in What Order

A calm, step-by-step learning path for beginners: HTML, CSS, JavaScript, developer tools, responsive and accessible design, a framework, TypeScript, and deployment, with the reasoning behind each step.

Sep 20, 202611 min read
Title card reading Styling and Interactivity over a dark blue ACY Partner background
Frontend / Fundamentals

How Styling and Interactivity Work

A beginner-friendly look at how CSS turns plain HTML into a designed layout, and how JavaScript adds behavior — the structure, style, behavior mental model for building web pages.

Sep 20, 20269 min read
Three front-end layers combining on one web page
Frontend / Fundamentals

How HTML, CSS, and JavaScript Work Together

A hands-on walkthrough for beginners: build one small button, give it structure with HTML, looks with CSS, and behavior with JavaScript, and watch the three layers cooperate on a real page.

Sep 20, 20268 min read
The Frontend Developer Toolkit cover with editor, browser, and CLI motifs
Frontend / Fundamentals

The Frontend Developer Toolkit

A friendly tour of the everyday tools a frontend developer relies on — code editor, browser and DevTools, terminal, version control, package managers, and a dev server — and what each one is actually for.

Sep 20, 202610 min read
Cover illustration for What Frontend Developers Do
Frontend / Fundamentals

What Frontend Developers Do: A Beginner's Guide to the Role

A clear, beginner-friendly look at what frontend developers actually do every day: turning designs into working interfaces, building reusable UI, and caring about responsiveness, accessibility, and speed.

Sep 20, 202610 min read