CSS for Beginners: How to Style Your First Web Page

CSS for Beginners: How to Style Your First Web Page

After learning HTML, the next important step in web development is CSS. HTML creates the structure of a web page, but CSS makes it beautiful and attractive.

Without CSS, every website would look plain and boring. In this beginner-friendly guide, you will learn what CSS is, how it works, and how to style your first web page step by step.


What Is CSS?

CSS stands for Cascading Style Sheets. It is used to control the design and appearance of a web page.

CSS can change:

  • Colors
  • Fonts
  • Spacing
  • Layout
  • Alignment

In simple words:

  • HTML = Structure
  • CSS = Design

How CSS Works with HTML

CSS styles HTML elements by selecting them and applying design rules.

Example:

h1 {
  color: blue;
}

This means: “All <h1> headings should appear in blue color.”


Three Ways to Add CSS

1. Inline CSS

CSS written directly inside an HTML tag:

<h1 style="color:red;">Hello</h1>

⚠️ Not recommended for large projects.

---

2. Internal CSS

CSS written inside the <style> tag in the HTML file:

<head>
  <style>
    body {
      background-color: lightgray;
    }
  </style>
</head>

✅ Good for small beginner projects.

---

3. External CSS (Best Method)

CSS stored in a separate file like style.css.

HTML file:

<link rel="stylesheet" href="style.css">

CSS file:

body {
  background-color: lightblue;
}

✅ Best and most professional method.


Basic CSS Properties Every Beginner Should Know

1. Text Color

p {
  color: green;
}

2. Background Color

body {
  background-color: #f2f2f2;
}

3. Font Size

h1 {
  font-size: 32px;
}

4. Font Family

body {
  font-family: Arial, sans-serif;
}

5. Spacing (Margin & Padding)

p {
  margin: 20px;
  padding: 10px;
}

Margin = space outside the element Padding = space inside the element


Simple Example: Styling a Web Page

Here is a full beginner example:

<!DOCTYPE html>
<html>
<head>
  <title>My Styled Page</title>
  <style>
    body {
      background-color: #eef;
      font-family: Arial, sans-serif;
      text-align: center;
    }

    h1 {
      color: darkblue;
    }

    p {
      font-size: 18px;
      color: #333;
    }
  </style>
</head>

<body>
  <h1>Welcome to My Website</h1>
  <p>I am learning HTML and CSS!</p>
</body>
</html>

Save and open this file to see the styling in action.


Common Beginner Mistakes in CSS

1. Forgetting the Semicolon (;)

color: red   ❌
color: red;  ✔️
---

2. Misspelling Property Names

colr: blue; ❌
color: blue; ✔️
---

3. Mixing HTML and CSS Incorrectly

Keep CSS inside <style> or a separate file.


What to Learn After CSS?

Once you understand basic CSS, the next step is:

  • JavaScript → to add interactivity
  • Responsive design → make websites mobile-friendly
  • Real projects → build portfolios and apps

This is how beginners become real web developers.


Final Thoughts

Learning CSS is an exciting step because your web pages finally start to look modern and professional.

Don’t try to memorize everything. Instead, practice by styling small projects again and again.

The more you practice, the better designer and developer you will become. 🚀

Comments

Popular posts from this blog

How to Center a Div - The 3 Modern Ways (2026)

Call by Value vs Call by Reference in C Programming (With Simple Examples)

Build a Simple Calculator with HTML, CSS & JavaScript