Skip to content

Adding Line Breaks and Images In HTML | Lecture 7

Adding Line Breaks and Images In HTML

Let’s begin with Lecture 7 of the HTML5 & CSS3 series. Adding Line Breaks and Images in HTML. This lecture is for absolute beginners; even kids can follow along and understand.

🎯 Objective:

By the end of this lecture, you will:

  • Know how to add line breaks using the <br> tag
  • Be able to insert images on your webpage using the <img> tag
  • Understand how to use image attributes like src, alt, width, and height
  • Create a fun page with text and images together

💬 The <br> Tag – Add Line Breaks

Sometimes, you want to start a new line without starting a whole new paragraph.

Think of it like this:

If paragraphs are like sentences in a storybook, then <br> is like pressing “Enter” to go to the next line!

Example:
<p>This is line one.<br>This is line two!</p>

🎯 Output:

This is line one.
This is line two!

⚠️ Note: <br> It is a self-closing tag, so you don’t need </br>.

🖼️ The <img> Tag – Insert Images

Images make your website more interesting and colorful!

To show an image, we use the <img> tag with some special instructions:

Basic Syntax:
<img src="image.jpg" alt="Description of image">

Let’s break it down:

AttributeWhat It Does
srcTells the browser where the image is (file name or URL)
altDescribes the image if it doesn’t load
widthSets how wide the image should be
heightSets how tall the image should be

🔍 Example: Inserting an Image

<img src="cat.jpg" alt="A cute cat" width="200" height="150">

If you have a file named cat.jpg In your project folder, this code will show that image.

If not, you can also use an image from the internet:

<img src="https://example.com/images/cat.jpg"  alt="Online Cat Image">
Adding Line Breaks and Images In HTML
A cartoon kid clicks a button that says Insert Image and a picture of a smiling dog appears on the screen

💻 Try This: Make a Fun Page with Text and Images

Let’s create a new HTML file that shows off line breaks and images.

Step 1: Create a New File

In your VS Code project folder (MyFirstWebsite), create a new file named:

my-fun-page.html

Step 2: Add This Code

<!DOCTYPE html>
<html>
<head>
    <title>Fun Page</title>
</head>
<body>
    <h1>Welcome to My Fun Page!</h1>

    <p>This is my favorite joke:<br>Why don't skeletons fight each other?<br>Because they don't have the guts!</p>

    <h2>My Favorite Animal</h2>
    <p>I love dogs because they are loyal, friendly, and always happy to see you.</p>
    <img src="dog.jpg" alt="A happy dog" width="300" height="200">

    <h2>My Avatar</h2>
    <img src="avatar.jpg" alt="My Profile Picture" width="150" height="150">
</body>
</html>

💡 Tip: You can replace "dog.jpg" and "avatar.jpg" With any image files you have saved in the same folder, or use online image URLs instead.

Step 3: Run with Live Server

Right-click the code → Show All Commands → Launch Live Server

🎉 You’ve just made a colorful, fun page with text and images!

🧪 Try It Yourself!

  1. Add a <br> Inside your joke, to make it easier to read.
  2. Replace the image paths with ones from the internet (like from https://picsum.photos/ ).
  3. Add another section about your favorite food with an image beside it.
  4. Try resizing the images by changing the width height.
🚀 Next Lecture Preview:

In Lecture 8, we’ll learn how to make clickable links using the <a> tag, just like the buttons you click in games or apps!

Stay Updated

If you found this information useful, don’t forget to bookmark this page and Share and leave your feedback in the comment section below.

HTML5 and CSS3 Compleate Series

PayPal Donate
PayPal Donate
Najeeb Alam

Najeeb Alam

Technical writer specializes in developer, Blogging and Online Journalism. I have been working in this field for the last 20 years.

Leave a Reply

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