INTRODUCTION TO CSS (Cascading Style Sheets)

What Exactly Is CSS ?

  • CSS is a language that describes the style of an HTML Document.
  • Describes how an HTML element should be displayed.
  • It is a simply designed language intended to simplify the process of making web pages presentable
  • It allows you to apply Style to web pages.

🎨 Why Do We Need CSS? 

If HTML is the stuff that makes up the webpage (the actual text, the pictures, the links), then CSS is what tells the computer how all that stuff should look.

Think about your favorite actor getting ready for a huge movie premiere.

🧱 HTML is Just the Structure

Imagine the actor standing there. They have a body, arms, legs, and a face. That's HTML.

  • HTML says: "Here is a title (the head), here is a paragraph (the body), and here is a photo (the face)."
  • Without CSS, the webpage (like the actor) is just standing there unstyled! Everything is in the right place, but it’s just a plain white page, which isn't very inviting.

🖌️ CSS is the Stylist and Designer

Now, CSS steps in, grabs the colors, and says, "Let's turn this into something beautiful!"

  • CSS says:
    • "The title needs to be huge and bright yellow."
    • "We should put a nice shadow under the pictures."
    • "Let's move all the text over to the left side and give the whole page a dark blue background."

The Two Reasons We Can't Live Without CSS:

  1. It Makes Things Look Good! (No one wants to read ugly websites.) CSS controls all the fonts, colors, spacing, and cool animations. It turns boring, plain text into a website that's easy to read and fun to use.

  2. It Saves You Tons of Effort! (The Master Switch) Let's say you have 50 different pages on your blog, and you decide you want all the main titles to be green instead of red.
    • Without CSS: You'd have to go into all 50 pages and manually change the color code 50 times. (What a pain!)
    • With CSS: You change one single line in your CSS file, and instantly, the titles on all 50 pages turn green at the same time!

This is why CSS is the backbone of modern web design.

⭐ The 3 Types of CSS

There are three different ways, and each one has its own purpose — kind of like using different tools depending on the situation.

1️⃣ Inline CSS — The “Instant Fix” Method

  • Not changing the whole outfit… just adjusting one button.
  • It's very specific and messy if you have a lot of items.
<p style="color: blue; font-size: 18px;">Hello, this text is blue!</p>

📝 When people use inline CSS:

  • When they want to fix something quickly.
  • When only one element needs styling.
  • When they are testing something small.

❌ Why it’s not great:

If you try to design a whole website this way, you’ll go crazy.
Imagine changing the color for 50 paragraphs manually. No one has that time.

2️⃣ Internal CSS — The “One Page Designer”

Internal CSS sits inside the <style> tag in the <head> part of the HTML.
<head>
<style type="text/css">
    h1
    {
        color: red;
        text-align: center;
    }
    p
    {
        color: gray;
    }
</style>
<title></title>
</head>

📝 When it’s useful:

  • When you want styling for just one page
  • When you're testing page-level designs
  • When the website is small

❌ Downside:

If your site has 20 pages, you'd have to put this CSS in every page.
That gets messy really fast.

3️⃣ External CSS — The “Professional & Clean Method”

  • This is the method every proper website uses.
  • You create a separate style file (e.g., styles.css). 

👉 Example:

HTML file:

<head>
<link rel="stylesheet" href="styles.css">
<title></title>
</head>
styles.css file:
h1
{
    color: green;
}
p
{
font-size: 18px;
}

📝 Why this is the best:

  • One CSS file can style 100+ pages
  • Easy to manage
  • Looks clean and professional
  • You only change things once and they update everywhere

🌍 Real-life example:

If you decide all your buttons should be blue instead of black,
you change one line in the CSS file — and the whole site updates instantly.

Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.