Day 4 – HTML Links, Images & Lists

πŸ“˜ Day 4 – HTML Links, Images & Lists


πŸ“₯ Want the Notes as PDF?

πŸ“„ Download Day 4 Notes PDF


πŸ”— 1. HTML Links – The <a> Tag

βœ… Definition:

An HTML link (or hyperlink) allows users to navigate from one page to another, either within your website or to an external site.

βœ… Syntax:

<a href="https://example.com">Click Here</a>

βœ… Attributes:

  • href: Specifies the URL of the page the link goes to.

  • target="_blank": Opens the link in a new tab.

  • title: Adds a tooltip when hovering.

βœ… Example:

<a href="https://www.youtube.com" target="_blank" title="Visit YouTube">Go to YouTube</a>

βœ… Use Case:

Used for menus, navigation bars, linking to other sites or documents (PDFs, downloads).


πŸ–ΌοΈ 2. HTML Images – The <img> Tag

βœ… Definition:

The <img> tag is used to display images on a webpage. It is a self-closing tag.

βœ… Syntax:

<img src="image.jpg" alt="Description">

βœ… Attributes:

  • src: Path to the image file.

  • alt: Text shown when the image is not available.

  • width and height: Resize the image.

βœ… Example:

<img src="https://via.placeholder.com/300" alt="Sample Image" width="300" height="200">

βœ… Use Case:

Used to visually enhance web pages, add logos, product images, etc.


πŸ“‹ 3. HTML Lists – Displaying Multiple Items

HTML supports 3 types of lists:


πŸ”Ή A. Unordered List (<ul>)

Displays items with bullets.

<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>

πŸ”Ή B. Ordered List (<ol>)

Displays items with numbers.

<ol>
<li>Wake up</li>
<li>Brush Teeth</li>
<li>Start Coding</li>
</ol>

πŸ”Ή C. Description List (<dl>)

Used to list terms and definitions.

<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language</dd>

<dt>CSS</dt>
<dd>Cascading Style Sheets</dd>
</dl>


βœ… Use Case:

  • <ul>: For navigation menus, feature lists.

  • <ol>: For step-by-step instructions, ranked items.

  • <dl>: For glossaries, FAQs.


πŸ›  Complete Example – Links, Images & Lists

<!DOCTYPE html>
<html>
<head>
<title>Day 4 - Links, Images & Lists</title>
</head>
<body>
<h1>Day 4: Links, Images & Lists</h1>
<h2>1. Link to Google</h2>
<a href="https://www.google.com" target="_blank">Visit Google</a>
<h2>2. Display an Image</h2>
<img src="https://via.placeholder.com/250" alt="Placeholder Image" width="250">
<h2>3. Unordered List</h2>
<ul>
<li>Apple</li>
<li>Banana</li>
<li>Cherry</li>
</ul>
<h2>4. Ordered List</h2>
<ol>
<li>Login</li>
<li>Learn HTML</li>
<li>Build Websites</li>
</ol>
<h2>5. Description List</h2>
<dl>
<dt>Frontend</dt>
<dd>The part of website you see and interact with.</dd>

<dt>Backend</dt>
<dd>The server-side logic and database handling.</dd>
</dl>
</body>
</html>

βœ… Key Takeaways

  • Use <a> to create clickable links.

  • Use <img> to display images.

  • Use <ul>, <ol>, and <dl> for listing content.

  • Always use alt with <img> for accessibility and SEO.

  • Lists and links are essential for structuring website content.


πŸ§ͺ Practice Tasks

  1. Create a web page with:

    • One clickable link

    • One image

    • One list of your favorite 5 movies

  2. Try combining all three elements into a single mini project page.


❓ Practice Questions

  1. What is the difference between <ul> and <ol>?

  2. What is the role of alt in an <img> tag?

  3. Write the HTML code to open β€œhttps://example.com” in a new tab.

  4. Create an unordered list of your 3 hobbies.

  5. Explain the difference between <dl> and <ol> with an example.

Leave a Reply

Your email address will not be published. Required fields are marked *