📚 College Credit Guide ✓ UPI Study 🕐 10 min read

How Do You Use Images, Icons, and Favicons in HTML?

This article shows how to add images in HTML, write alt text that helps people and search engines, and link icons and favicons the right way.

US
UPI Study Team Member
📅 August 18, 2026
📖 10 min read
US
About the Author
The UPI Study team works directly with students on credit transfer, degree planning, and course selection. We've helped thousands of students figure out what counts toward their degree and how to finish faster without paying more than they have to. This post is written the way we'd explain it to you directly.
🦉

Images in HTML come from the img tag, and that tag does one job: it places a picture on the page. You point it to a file with src, give it alt text, and set basic sizes when you need them. Icons and favicons work differently. They live in the browser chrome, not inside your page content, and you usually link them in the head section with a rel value like icon or shortcut icon. The biggest mistake students make is sloppy file paths. A local image in the same folder uses a short relative path. A file inside an images folder needs that folder name in the path. A picture from another site uses a full URL, and that can break if the host blocks hotlinking or the file moves. Bad alt text causes the same kind of mess. If the image shows a chart, the alt text should say what the chart means, not just "image1" or "photo." A clean setup saves time later. A 24x24 favicon can sit beside a tab title all day, while a 1200x800 hero image can fill the top of a page without stretching or blurring. If you keep the file names, paths, and alt text straight from the start, HTML feels simple instead of sloppy.

Introduction to HTML and CSS
College credit · ACE & NCCRS reviewed · self-paced
View course
Open laptop with visible code on screen on a wooden desk in a modern, cozy workspace — UPI Study

How Do You Add Images in HTML?

The img element adds an image to a webpage with one tag, and the src attribute tells the browser exactly which file to load. A simple tag can point to a local file like images/cat.jpg or a full URL like https://example.com/cat.jpg, and both work if the path is correct.

Relative paths matter because they follow your folder structure, not some magic rule. If your HTML file sits in the root folder and your picture lives in an images folder, you write src="images/promo-banner.png". If the image sits next to the HTML file, you just write src="banner.png". That small difference saves hours of head-scratching, especially in a 5-page school project or a 20-page site where one broken path can ruin half your layout.

The catch: A browser does not guess file names, so Logo.png and logo.png can act like two different files on some systems. That tiny capitalization problem has burned plenty of students, and it usually shows up after a 2-hour editing session when the page finally looks right except for one missing image.

A local file works best for class projects, portfolios, and pages you control. A URL works when the image lives on another server, but that setup can fail if the remote site changes the file or blocks access. If you want a clean start, keep your files in one images folder, use short names with no spaces, and practice the path setup in an Introduction to HTML and CSS style project.

Which img Attributes Matter Most?

The basic img attributes do four jobs at once: they help browsers load the file, help people understand it, and stop layout jumps on a page. You only need a few at first, but those few decide whether your image looks clean or clumsy on a 1,200-pixel-wide layout.

Why Is Alt Text So Important?

Alt text matters because it gives meaning to an image when the image itself fails, and that failure happens more often than people admit. Screen readers rely on alt text, search engines use it as a clue, and a broken file can leave the browser showing only a missing-image icon instead of a blank mystery.

A good alt line says what the image does in context. If you show a 3-step cooking graphic, write something like "Three steps for mixing dough in a 10-inch bowl" instead of "dough picture." If the image only decorates the page, use empty alt text like alt="" so a screen reader skips it instead of wasting time on noise. That sounds small, but it matters on pages with 8, 12, or 20 images because repeated junk gets annoying fast.

Reality check: Weak alt text is lazy writing. "Image of a dog" tells people nothing useful if the page sells pet food, but "Golden retriever catching a red ball" gives a real picture in 6 words. On the other hand, a decorative swirl beside a 2026 blog headline does not need a long description at all.

Bad alt text usually tries to sound clever or SEO-heavy, and that backfires. Better alt text stays short, plain, and specific. If a chart shows summer signups rose from 120 to 180, say that. If a logo sits in the header, say the company name and stop there. That is how you write for humans first and search engines second, and the order matters more than people think.

Introduction To Html Css UPI Study Course

Learn Introduction To Html Css Online for College Credit

This is one topic inside the full Introduction To Html Css course on UPI Study — a self-paced, online class that earns real college credit. Credits are ACE and NCCRS evaluated and transfer to partner colleges across the US and Canada. Courses start at $250 with no deadlines and lifetime access.

Explore HTML CSS Course →

How Do Icons and Favicons Work?

Icons and favicons are small images that stand for an app, brand, or page, and they show up outside the body of your HTML content. A favicon usually appears in the browser tab, bookmarks bar, history list, and sometimes on phone home screens, while a page icon or app icon can appear in menus or launchers.

Most favicons use square files like 16x16, 32x32, or 48x48 pixels, and common file types include .ico, .png, and sometimes .svg. That square shape matters because a browser tab gives you very little room. Try to cram a wide banner into that space and it turns into a blur. Nobody wants a tiny muddy logo sitting next to a tab title.

A favicon does not belong in the page body with an img tag. You link it in the head so the browser can find it before the page fully loads. That placement makes sense because the icon belongs to the whole site, not a single paragraph or card.

Worth knowing: A favicon acts like a visual shortcut, not decoration. On a page open in 12 tabs, people often spot the tab by the icon before they read the title, and that tiny 1-second cue saves real time. If you are building a site in an Introduction to HTML and CSS course, this is one of those details that makes beginner work look more polished than it is.

A favicon setup only works when the file, folder, and link tag all match. Miss one piece and the browser shows nothing, which is annoying because the fix usually takes 2 minutes once you spot the mistake.

  1. Pick a square icon file first, usually 32x32 pixels for modern browsers or 16x16 pixels for older tabs. A PNG works fine for most class projects, and an ICO file still helps when you want broad support.
  2. Put the file in your project folder, often beside index.html or inside an images folder. If you store it in images, keep the path short and exact, like images/favicon.png.
  3. Add a link tag inside the head section, not the body. Use something like <link rel="icon" href="images/favicon.png" type="image/png"> so the browser knows the file type.
  4. Check the path twice, because one wrong letter can kill the icon. A student building a small site for an online class at Miami Dade College can waste 30 minutes here if they name the file FavIcon.png in one place and favicon.png in another.
  5. Refresh the browser with a hard reload and open the page in a second tab. Favicons sometimes cache fast, so the old icon can stick around for 1 or 2 minutes even after you fix the file.
  6. Test the result in the browser tab, bookmarks bar, and history list. If you use a logo for a course project, keep the design simple so it still reads at 16x16.

A clean favicon setup helps any starter site look finished, and that matters in a first draft, not just a final demo.

How Do You Get and Work With Images Icons and Favicons?

Good image work starts before you write any code, because file choice changes everything. A crisp photo for a homepage hero might need 1200 pixels wide, while a favicon needs a tiny square file like 32x32 or 48x48. If you mix those up, the page will look sloppy fast.

For a real setup, think about a student building a simple portfolio for an Introduction to HTML and CSS course and wanting one site logo, three content images, and one favicon. They might use JPG for photos, PNG for logos with clear edges, and SVG for sharp icons that scale well. That mix keeps the file size sane and the page cleaner.

Bottom line: A small site can still look sharp when the assets match the job. If you use a 64x64 logo as a favicon and a 900x600 image in the body, you avoid ugly stretching and keep the browser happy.

One smart move is to name files by purpose, not by random numbers. logo-home.png beats final2.png every day. Another smart move is to keep a single images folder so you do not lose track of 4 files after 2 weeks. If you want practice with the file setup, the Introduction to HTML and CSS course page is a useful model for how a clean site can organize visuals without clutter.

Frequently Asked Questions about HTML Images

Final Thoughts on HTML Images

HTML images look simple until a bad path, weak alt text, or sloppy favicon setup wastes your time. That is the trap. The browser does not forgive missing files, and a screen reader does not care that you meant well. You need the right tag, the right path, and the right file format, every time. Start with the img tag for content images. Use src for the file location, alt for the meaning, and width or height when you want the page to hold its shape before the image loads. Keep decorative images quiet with empty alt text, and give useful images plain, specific descriptions that tell the truth in a few words. Favicons sit in a different spot. They belong in the head, not the body, and they work best as small square files like 16x16, 32x32, or 48x48 pixels. If the icon looks fuzzy in a tab, the file is too large, too messy, or linked with the wrong path. The smart move is to build a tiny test page and break it on purpose. Change one file name. Move one image into a new folder. Refresh the browser and watch what happens. That kind of practice teaches more than staring at notes for an hour. Once you can place one image, one icon, and one favicon without guessing, you have the core skill nailed down. From there, keep building cleaner pages and stop treating file paths like a mystery.

How UPI Study credits actually work

Ready to Earn College Credit?

ACE & NCCRS approved · Self-paced · Transfer to colleges · $250/course or $99/month

More on Introduction To Html Css
© UPI Study. This article and its educational content are solely owned by UPI Study and licensed under CC BY-NC-ND 4.0. It is not free to reuse or modify. Any citation must credit UPI Study with a direct link to this page.