Basics

Learn what CSS is, how it styles HTML, and understand its basic syntax with simple examples.

Loading...
Basics
  • CSS stands for Cascading Style Sheets.
  • It is used to style HTML elements (like changing colors, fonts, layouts).
  • Without CSS, websites would look plain and boring.
  • CSS makes websites beautiful, organized, and user-friendly.

For example:

HTML adds text:

<h1>Hello</h1>

CSS changes how it looks:

h1 {
  color: blue;
  font-size: 30px;
}

css-syntax-structure


Syntax and Structure

CSS has a simple pattern:

selector {
  property: value;
}
  • Selector: Picks the HTML element(s) you want to style.
  • Property: The style aspect you want to change, like color, font size, margin, etc.
  • Value: The specific setting you want for that property, like red for color or 16px for font size.

Example:

p {
  color: red;
}
  • p is the selector, meaning it targets all <p> (paragraph) elements in the HTML.
  • color is the property, which controls the text color.
  • red is the value, so all paragraph texts will be colored red.