Master the art of styling the web
CSS selectors target HTML elements for styling. They range from simple element selectors to complex combinations that precisely target specific elements.
/* Element selector */
p {
color: #333;
}
/* Class selector */
.highlight {
background: yellow;
}
/* ID selector */
#header {
font-size: 2rem;
}
This is a paragraph element.
This has a class.
This has an ID.
The CSS Box Model describes how elements are rendered as boxes with content, padding, borders, and margins.
.box {
width: 200px;
height: 100px;
padding: 20px;
border: 2px solid blue;
margin: 10px;
box-sizing: border-box;
}
Flexbox is a powerful layout system for arranging elements in one dimension (row or column) with flexible sizing and alignment.
.container {
display: flex;
justify-content: space-between;
align-items: center;
gap: 20px;
}
.item {
flex: 1;
}
CSS Grid is a two-dimensional layout system that allows you to create complex layouts with rows and columns.
.grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
}
.featured {
grid-column: span 2;
}
CSS provides multiple ways to define colors and create beautiful gradients for backgrounds and elements.
.solid {
background: #4C51BF;
}
.gradient {
background: linear-gradient(
135deg,
#667eea 0%,
#764ba2 100%
);
}
.rgba {
background: rgba(255, 0, 0, 0.5);
}
CSS animations and transitions bring your designs to life with smooth, performant motion effects.
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.animated {
animation: fadeIn 1s ease-in;
}
Write CSS and see it applied to HTML instantly