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.
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.
- alt gives text for screen readers and broken images. Write the purpose, not the file name.
- width and height set the image box size. Use real numbers like 300 and 200 so the page reserves space before the file loads.
- loading="lazy" delays images below the fold until a user scrolls near them. That helps pages with 10 or more images feel faster.
- title shows a small hover tip in some browsers. It does not replace alt text, and it should not repeat the whole sentence.
- srcset lets the browser pick a better file for different screens, such as 1x and 2x versions. Start simple, then add it when you have multiple image sizes.
- Do not stuff alt text with keywords. A bad example is "HTML image icon favicon HTML image icon" because it sounds fake and helps nobody.
- Do not stretch one 400x400 image into a 1200x300 box unless you want warped faces and ugly edges.
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.
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.
How Do You Link Favicons Correctly?
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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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
This applies to you if you want to add photos, icons, or a browser tab logo with HTML, and it doesn't apply if you only use text pages with no media. The `img` tag shows pictures in the page, while `link rel="icon"` points to a favicon.
You add an image with `
`, and you add a favicon with ``. If the file path is wrong or the `alt` text is empty, the browser shows a broken image or leaves screen readers with nothing useful.
If you get this wrong, the image may not load, the favicon may never show, and screen readers may miss the meaning of the picture. A bad path like `images/pic.png` when the file sits in `/assets/` gives you a broken icon in the browser.
Start by putting the file in your project folder and copying the exact file name, including `.jpg`, `.png`, or `.ico`. Then write the correct path in `src` for images or `href` for the favicon, and keep the file names simple with no spaces.
The most common wrong assumption is that `img` and favicon code work the same way, but they don't. `img` places content inside the page, while a favicon lives in the `
` and appears in the browser tab, bookmarks, and sometimes phone home screens.What surprises most students is that a favicon can be 16x16 or 32x32 pixels and still matter a lot because it appears in tiny spaces. A clear `.ico` or `.png` file helps the tab stand out, even on pages with 20 or more open tabs.
Use alt text to say what the image means, not just what file it is. `alt="Red bicycle"` works for a product photo, while decorative images can use empty alt text, but only if the image adds no information.
Most students drop in an image with no size control and hope it looks fine, but that causes huge files and slow pages. What works is using `width` and `height`, choosing the right file type like `.jpg` for photos and `.png` for sharp graphics, and keeping the image close to the size you need.
In an introduction to html and css course, you usually learn to save files in the same project folder, link them with relative paths, and place the favicon link inside `
`. That setup also helps when you're working toward college credit, an online course, or ace nccrs credit from a study online program.No, you can't treat page icons and regular images as the same thing, because icons often come from icon fonts, SVG files, or CSS classes instead of plain `` tags. A favicon still needs a browser tab link, while a page icon can sit inside the content area like any other graphic.
Favicons appear in the browser tab, the bookmarks bar, the history list, and sometimes on mobile home screens. You add them with `` inside the `
`, and browsers often look for a 16x16, 32x32, or 48x48 file.You link images with `` in the body and favicons with `` in the head, using the right path for each file. A clean setup uses one folder for images, one favicon file, and exact names like `logo.png` or `favicon.ico` with no typos.
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