A page becomes a website when pages are connected to each other and to the wider web. Images add meaning, frames embed other pages, and links make the connections.
Images
The <img> element shows a picture. It is an empty element with two main attributes: src, the file path or address of the picture, and alt, a short text description. The width and height attributes set the displayed size in pixels. Good images are small in file size, because large pictures slow the page.
The alt text appears when the image cannot load, and screen readers read it aloud to users who cannot see the picture. It should describe the purpose of the image in a few words.
Definition: Alt text. A short text description of an image, used when the image cannot be seen.
Hyperlinks
The anchor element <a> makes a link. The href attribute holds the destination, and the content between the tags is the clickable part, which may be text or an image.
Definition: Hyperlink. Text or an image that takes the user to another page or place when clicked.
A relative path names a file in relation to the current page, for example courses/bca.html. It is used inside your own site. An absolute path gives the full web address, for example https://www.example.com/page.html, and it is used for other sites. A link can also jump to a place inside a page: give an element an id, and link to it with href="#id". The attribute target="_blank" opens a link in a new tab.
Table 1.8: Kinds of link destination
| Kind | Example | Used for |
|---|---|---|
| Relative | href="about.html" |
A page in your own site |
| Absolute | href="https://example.com" |
Another website |
| Page section | href="#contact" |
A place in the same page |
href="mailto:a@b.com" |
Opening a mail program |
Frames
The <iframe> element shows another web page inside the current page, in a window of the size given by width and height. It is often used to embed maps and videos. Many sites refuse to be shown in a frame for security reasons, so the address should be tested before the page is published.
Example 1.8: A link and an image
<p>Visit the <a href="https://www.w3.org" target="_blank">W3C site</a>.</p>
<p><a href="#end">Jump to the end</a></p>
<img src="missing.png" alt="DPG ITM campus" width="140" height="60">
<p id="end">This is the end of the page.</p>
Output in the browser:
The image file does not exist here, so the browser shows the alt text. This is why alt text matters.
Common mistakes
- Leaving out the alt attribute, or writing a useless value such as image.
- Using an absolute path for a file in your own site, which breaks the link when the site moves.
- Placing the image file in a different folder from the path written in src.
- Using link text such as click here, which says nothing about the destination.
Key takeaways
- The img element needs src for the file and alt for the description.
- The a element with href makes a link, and a relative path stays inside your site.
- An iframe embeds another page, and not every site allows it.
- Write link text that describes the destination.
Practice questions
- What is the purpose of the alt attribute?
- What does target="_blank" do?
- Write a link that goes to a section with the id contact.
Answers to the practice questions
- It describes an image in words for users who cannot see it and appears if the image fails to load.
- It opens the linked page in a new tab.
- The a element with href set to #contact.
Sources
- Official BCA syllabus (NEP 2025 scheme), Web Application Development, course code 25BCA405DS04, Unit I
