Learn CSS – Styling the Web

Great! Let’s continue with Lesson 5 — it’s time to make things look beautiful with CSS 🎨


📘 LESSON 5: Learn CSS – Styling the Web

Learning Goals:

  • Understand what CSS is and why it’s important
  • Learn basic CSS syntax and how to link it to HTML
  • Style text, colors, spacing, and layout
  • Write your first styled webpage

🧾 Lesson Content (Text for Website)


🎨 What is CSS?

CSS stands for Cascading Style Sheets.
It controls how your HTML content looks and feels — fonts, colors, sizes, spacing, layout, and more!

If HTML is the structure, then CSS is the paint, decorations, and layout.


🧠 CSS Syntax

CSS is written using this pattern:

selector {
  property: value;
}

✅ Example:

h1 {
  color: red;
  font-size: 36px;
}

This will make all <h1> elements red and big.


👕 Three Ways to Add CSS

MethodDescriptionExample
Inline CSSInside an HTML tag (not recommended)<h1 style="color:red">
Internal CSSInside a <style> tag in HTML fileSee below
External CSS ✅Linked in a separate .css fileBest practice

🧪 Internal CSS Example

<!DOCTYPE html>
<html>
<head>
  <title>Styled Page</title>
  <style>
    body {
      background-color: #f5f5f5;
      font-family: Arial;
    }
    h1 {
      color: #ff6f00;
    }
    p {
      color: #333;
    }
  </style>
</head>
<body>
  <h1>This is a styled heading</h1>
  <p>CSS makes things beautiful!</p>
</body>
</html>

🧪 External CSS Example

  1. Create a file style.css:
body {
  background-color: white;
  font-family: sans-serif;
}
h1 {
  color: #ff0000;
}
  1. Link it in your HTML:
<link rel="stylesheet" href="style.css" />

🧰 Common CSS Properties

PropertyDescription
colorText color
background-colorBackground color
font-sizeSize of the text
font-familyType of font
paddingSpace inside an element
marginSpace outside an element
borderAdds border around elements
text-alignAligns text left, center, right

📌 Try It Yourself

Create lesson5.html and style.css, then connect them.

HTML:

<!DOCTYPE html>
<html>
<head>
  <title>Styled Webpage</title>
  <link rel="stylesheet" href="style.css" />
</head>
<body>
  <h1>Welcome to CSS World</h1>
  <p>This page is styled using external CSS!</p>
</body>
</html>

CSS (style.css):

body {
  background-color: #f0f0f0;
  color: #333;
}
h1 {
  color: #ff6f00;
}

Open lesson5.html in your browser to see your first styled webpage!


💪 Practice Task

✅ Create a page that includes:

  • A colored background
  • Two different heading styles
  • A paragraph with padding and custom font
  • A button with styled color and border-radius

📌 Quick Summary

  • CSS makes your websites look awesome
  • It’s written using selectors, properties, and values
  • You can add CSS inline, internally, or externally
  • Use external CSS for clean and reusable code

🔗 Next Lesson:

👉 Lesson 6: CSS Box Model – Understanding Spacing

Telegram Join Our Telegram Channel

One Response

  1. Pingback: ZRTech Solutions

Leave a Reply

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

Telegram Join Our Telegram Channel

Most Viewed

Monthly Best Selling Templates

Check the latest products added to the marketplace. Fresh designs with the finest HTML5 CSS3 coding.