8 months ago|
Tech

Introduction to CSS: Styling the Web

Learn the basics of CSS, its types, syntax, and how it's used to make web pages attractive and user-friendly.

Editor

Author at Billianz

  • Jun 27, 2025
  • 5 min read
  • 11

What is CSS?

CSS (Cascading Style Sheets) is a stylesheet language used to describe the appearance and layout of HTML elements on a web page. It controls how your website looks on all devices.

Why Use CSS?

  1. Separate content from design
  2. Make sites responsive and mobile-friendly
  3. Add animations and transitions
  4. Create consistent designs across pages
  5. Reduce code repetition with classes and selectors

Types of CSS

There are three main ways to apply CSS to your HTML:

  1. Inline CSS
  2. Directly inside the HTML element using the style attribute.
<p style="color:blue;">Hello CSS</p>
  1. Internal CSS
  2. Inside a <style> tag within the HTML file's <head>.
<style>
p {
color: green;
}
</style>
  1. External CSS
  2. Linked through a separate .css file. Best practice for real-world projects.
<link rel="stylesheet" href="style.css" />

Basic CSS Syntax

selector {
property: value;
}

Example:

body {
background-color: #f5f5f5;
font-family: Arial;
}

Popular CSS Properties

  1. color: Sets text color
  2. background-color: Sets background color
  3. font-size: Controls text size
  4. margin: Space outside an element
  5. padding: Space inside an element
  6. border: Adds borders
  7. width and height: Set dimensions

Selectors in CSS

Selectors target the HTML elements you want to style.

  1. * - Universal selector
  2. p - Element selector
  3. .class-name - Class selector
  4. #id-name - ID selector
  5. div p - Descendant selector

Responsive Design with CSS

Using media queries and flexible units like %, em, and vh, you can make websites look good on all screen sizes.

@media (max-width: 600px) {
body {
background-color: lightblue;
}
}

CSS in Action: Simple Example

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
color: red;
text-align: center;
}
p {
font-size: 18px;
}
</style>
</head>
<body>
<h1>Welcome to CSS</h1>
<p>This paragraph is styled using CSS.</p>
</body>
</html>

Conclusion

CSS is the magic that brings life and beauty to your web pages. Whether you're building a portfolio, a landing page, or a full website, CSS gives you the power to control every visual detail.


Stay tuned with Billianz Academy for more beginner-friendly tutorials and real-time projects!


No comments yet

Be the first to share your thoughts!

Your Views Please!

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

You may also like