π Day 4 β HTML Links, Images & Lists
π₯ Want the Notes as 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:
β 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:
β 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:
β Attributes:
-
src
: Path to the image file. -
alt
: Text shown when the image is not available. -
width
andheight
: Resize the image.
β Example:
β 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.
πΉ B. Ordered List (<ol>
)
Displays items with numbers.
πΉ C. Description List (<dl>
)
Used to list terms and definitions.
β 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
β 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
-
Create a web page with:
-
One clickable link
-
One image
-
One list of your favorite 5 movies
-
-
Try combining all three elements into a single mini project page.
β Practice Questions
-
What is the difference between
<ul>
and<ol>
? -
What is the role of
alt
in an<img>
tag? -
Write the HTML code to open βhttps://example.comβ in a new tab.
-
Create an unordered list of your 3 hobbies.
-
Explain the difference between
<dl>
and<ol>
with an example.