Intro to CSS

CSS (Cascading Style Sheets) is the language that brings life and style to the web. While HTML provides the structure and content of a webpage, CSS is what makes it visually appealing, controlling everything from colors and fonts to layouts and animations.

What is CSS?

CSS is a stylesheet language used to describe the presentation of HTML documents. It allows you to separate content from design, making your websites more maintainable and flexible. With CSS, you can:

  • Control colors, fonts, and typography
  • Create responsive layouts that work across devices
  • Add animations and transitions
  • Position elements precisely on the page
  • Style multiple pages from a single stylesheet

CSS Basics

Syntax

CSS follows a simple pattern:

selector {
  property: value;
}

For example:

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

Selectors

CSS selectors target HTML elements to apply styles:

  • Element selector: p { } - targets all <p> tags
  • Class selector: .classname { } - targets elements with class="classname"
  • ID selector: #idname { } - targets element with id="idname"
  • Descendant selector: div p { } - targets <p> inside <div>
  • Pseudo-classes: a:hover { } - targets specific states

The Box Model

Every element in CSS is essentially a box with:

  • Content: The actual content (text, images, etc.)
  • Padding: Space inside the element, around the content
  • Border: A line around the padding
  • Margin: Space outside the element

Common Properties

  • color - text color
  • background-color - background color
  • font-size - text size
  • margin - outer spacing
  • padding - inner spacing
  • border - element border
  • display - how element is displayed (block, inline, flex, grid)
  • position - positioning method (static, relative, absolute, fixed)

Modern CSS Features

CSS has evolved significantly with powerful features like:

  • Flexbox: One-dimensional layouts
  • Grid: Two-dimensional layouts
  • Custom Properties (CSS Variables): Reusable values
  • Media Queries: Responsive design
  • Transforms & Transitions: Animations and effects

Useful Resources

Official Documentation

Learning Platforms

Interactive Tools

References & Cheat Sheets

Communities & Inspiration

Getting Started

The best way to learn CSS is by doing. Start with simple styling, experiment with properties, and gradually work your way up to complex layouts. Use browser developer tools (F12) to inspect and modify CSS in real-time—it’s an invaluable learning tool.

Remember: CSS is forgiving and encourages experimentation. Don’t be afraid to try things and see what happens!