CSS
Anatomy

styles.css

Master the art of styling the web

01

Selectors

CSS selectors target HTML elements for styling. They range from simple element selectors to complex combinations that precisely target specific elements.

selectors.css
/* Element selector */
p {
  color: #333;
}

/* Class selector */
.highlight {
  background: yellow;
}

/* ID selector */
#header {
  font-size: 2rem;
}

Try It:

This is a paragraph element.

This has a class.

This has an ID.

02

Box Model

The CSS Box Model describes how elements are rendered as boxes with content, padding, borders, and margins.

box-model.css
.box {
  width: 200px;
  height: 100px;
  padding: 20px;
  border: 2px solid blue;
  margin: 10px;
  box-sizing: border-box;
}

Box Model Visualization:

margin
border
padding
content
03

Flexbox

Flexbox is a powerful layout system for arranging elements in one dimension (row or column) with flexible sizing and alignment.

flexbox.css
.container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.item {
  flex: 1;
}

Try It:

1
2
3
04

CSS Grid

CSS Grid is a two-dimensional layout system that allows you to create complex layouts with rows and columns.

grid.css
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.featured {
  grid-column: span 2;
}

Grid Layout:

1
3
4
5
05

Colors & Gradients

CSS provides multiple ways to define colors and create beautiful gradients for backgrounds and elements.

colors.css
.solid {
  background: #4C51BF;
}

.gradient {
  background: linear-gradient(
    135deg,
    #667eea 0%,
    #764ba2 100%
  );
}

.rgba {
  background: rgba(255, 0, 0, 0.5);
}

Color Examples:

Solid
Gradient
RGBA
06

Animations & Transitions

CSS animations and transitions bring your designs to life with smooth, performant motion effects.

animations.css
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.animated {
  animation: fadeIn 1s ease-in;
}

Try It:

Animated Box

CSS Playground

Write CSS and see it applied to HTML instantly

CSS Editor
localhost:3000/preview