Logo
TUTORIAL

Welcome to the World of CSS 🎨

If HTML is the skeleton of a building, CSS (Cascading Style Sheets) is the paint, the furniture, and the decoration. CSS is what makes a website look professional, clean, and beautiful.

What is CSS?

CSS is a language used to describe the presentation of a web page. It handles the layout, colors, fonts, and even animations. By separating CSS from HTML, you can change the look of an entire website just by editing one file.

1. Understanding the Syntax

CSS works on a simple Selector-Declaration rule. You pick an HTML element (Selector) and tell it how to look (Declaration).

CSS Rule Structure:

/* Selector { Property: Value; } */ h1 { color: #3498db; /* Set text color */ font-size: 24px; /* Set text size */ text-align: center; /* Center the text */ }

2. Common CSS Functions

CSS isn't just static values; it has powerful built-in functions to perform calculations and handle colors dynamically.

Function Description Example
rgb() / rgba() Defines colors using Red, Green, Blue. 'a' is for transparency. rgba(255, 0, 0, 0.5)
calc() Allows mathematical calculations for sizes. width: calc(100% - 20px);
url() Used to link external images or fonts. background-image: url('bg.jpg');
var() Used to insert a CSS variable value. color: var(--main-color);
linear-gradient() Creates smooth color transitions. background: linear-gradient(to right, red, blue);

3. Three Ways to Add CSS

There are three common methods to apply styles to your HTML elements:

Example: External Link

<!-- Inside the <head> section --> <link rel="stylesheet" href="style.css">

4. The Box Model (Quick Preview)

In CSS, every element is considered a box. Understanding the Margin, Border, Padding, and Content is the key to mastering layout. We will dive deeper into this in the next lessons.

Human Tip: When you start learning CSS, don't try to memorize everything. Use the browser "Inspect Element" (F12) to play with styles in real-time. It's the fastest way to learn!

IDE Settings

X