Complete CSS Cheat Sheet
Complete CSS Cheat Sheet
1. Selectors
CSS selectors are used to select the HTML elements you want to style. Common types include:
/* Universal Selector */
* {
margin: 0;
padding: 0;
/* Class Selector */
.classname {
color: red;
/* ID Selector */
#idname {
font-size: 20px;
/* Attribute Selector */
input[type="text"] {
}
Comprehensive CSS Cheat Sheet
2. Colors
CSS supports color names, HEX, RGB, RGBA, HSL, and HSLA formats for styling elements.
/* Named Colors */
color: blue;
/* HEX Colors */
background-color: #ff5733;
/* RGB Colors */
/* RGBA Colors */
/* HSL Colors */
3. Box Model
Every element in CSS is a rectangular box defined by margins, borders, padding, and the content itself.
div {
Comprehensive CSS Cheat Sheet
width: 100px;
height: 100px;
padding: 10px;
margin: 20px;
4. Flexbox
CSS Flexbox provides a way to layout elements in a container. It's useful for responsive designs.
/* Flexbox Example */
.container {
display: flex;
justify-content: center;
align-items: center;
.item {
flex: 1;
padding: 10px;
5. Grid
CSS Grid is a two-dimensional layout system for arranging items into rows and columns.
Comprehensive CSS Cheat Sheet
/* Grid Example */
.container {
display: grid;
grid-gap: 10px;
.item {
background: lightblue;
/* Transition Example */
button {
background: blue;
button:hover {
background: green;
}
Comprehensive CSS Cheat Sheet
/* Keyframe Animation */
@keyframes slideIn {
from {
transform: translateX(-100%);
to {
transform: translateX(0);
div {