HTML & CSS

What is CSS? A Beginner’s Guide to Styling Web Pages

What is CSS?

CSS stands for Cascading Style Sheets.
It is used to style and design web pages.

While HTML creates the structure of the webpage, CSS makes it look beautiful — by adding colors, fonts, sizes, layouts, and much more.

💡 Without CSS, every website would look like black text on a white background!

🔧 What Can CSS Do?

With CSS, you can:

  • Change text color, size, and spacing
  • Add background colors or images
  • Design buttons, cards, layouts
  • Make your site responsive (mobile friendly)

📄 Example: Basic CSS Code

<!DOCTYPE html>
<html>
  <head>
    <style>
      h1 {
        color: blue;
        font-size: 30px;
      }
      p {
        color: gray;
        font-family: Arial;
      }
    </style>
  </head>
  <body>
    <h1>This is a Heading</h1>
    <p>This is a paragraph.</p>
  </body>
</html>

This code changes the heading color to blue and the paragraph font to Arial.

3 Ways to Apply CSS

MethodDescriptionExample
Inline CSSDirectly in the tag<h1 style="color: red;">Hi</h1>
Internal CSSInside <style> tag in <head>(like the code above)
External CSSLinked .css file<link rel="stylesheet" href="style.css">

🟢 External CSS is the best method — clean and reusable.


🖥️ Create Your First CSS File

  1. Open Notepad or VS Code
  2. Paste this code:
body {
  background-color: #f0f0f0;
  font-family: sans-serif;
}

h1 {
  color: green;
  text-align: center;
}

p {
  color: #333;
}
  1. Save it as style.css
  2. Link it in your HTML:
<link rel="stylesheet" href="style.css">

Done! Your page will now have your own custom styles!

Common CSS Properties for Beginners

PropertyWhat it Does
colorText color
font-sizeSize of text
backgroundBackground color or image
marginSpace outside the element
paddingSpace inside the element
borderAdds border around an element
text-alignAligns text (left, center, right)

🔄 What Does “Cascading” Mean in CSS?

“Cascading” means that if two styles target the same element, the one that is more specific or written later will apply.

For example:

h1 {
  color: red;
}
h1 {
  color: blue;
}

Result: Heading will be blue because it was defined last.

CSS is Everywhere!

Big websites like:

  • YouTube
  • Amazon
  • Instagram

…all use CSS to control their layouts and styles.

Even dark mode, animations, and modern layouts — all are done using CSS.

💬 Ask Yourself:

  • Can you change the background color of your page?
  • Can you center a heading with CSS?
  • Try styling a simple resume page from yesterday’s HTML file.

🧠 Summary

You Learned Today
✅ What CSS is
✅ How to write CSS code
✅ Inline, internal, and external
✅ Common properties like color, font, padding
✅ Created your first styled webpage

💬 Comment Prompt

🎨 Try changing the heading color on your own webpage.
Post a screenshot or ask for help if you’re stuck — we’ll guide you!

📥 Join our Telegram group → @LearnNewThingsHub

Loading

Leave a comment

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