CSS Cheat Sheet

🎯 CSS Selectors
* { } /* Universal selector */
element { } /* Type selector */
.class { } /* Class selector */
#id { } /* ID selector */
element.class { } /* Element with class */
element, element { } /* Multiple selectors */
element element { } /* Descendant */
element > element { } /* Direct child */
element + element { } /* Adjacent sibling */
πŸ“ Layout Properties
display: block | inline | inline-block | flex | grid | none
width: auto | 100px | 50% | 100vw
height: auto | 100px | 50% | 100vh
max-width: none | 500px | 80%
min-height: 0 | 200px | 100vh
box-sizing: content-box | border-box
overflow: visible | hidden | scroll | auto
πŸ”„ Flexbox
display: flex
flex-direction: row | column | row-reverse | column-reverse
justify-content: flex-start | center | flex-end | space-between | space-around | space-evenly
align-items: stretch | flex-start | center | flex-end | baseline
flex-wrap: nowrap | wrap | wrap-reverse
flex-grow: 0 | 1 | 2
flex-shrink: 1 | 0
flex-basis: auto | 200px | 50%
⚏ CSS Grid
display: grid
grid-template-columns: 1fr 1fr | repeat(3, 1fr) | 100px auto
grid-template-rows: auto | 100px 200px
grid-gap: 10px | 1rem 2rem
grid-column: 1 / 3 | span 2
grid-row: 1 / 3 | span 2
grid-area: header | 1 / 1 / 2 / 4
πŸ”€ Typography
font-family: Arial, sans-serif | "Times New Roman", serif
font-size: 16px | 1.2em | 1.5rem
font-weight: normal | bold | 400 | 700
font-style: normal | italic | oblique
line-height: normal | 1.5 | 24px
text-align: left | center | right | justify
text-decoration: none | underline | line-through
text-transform: none | uppercase | lowercase | capitalize
letter-spacing: normal | 2px | 0.1em
🎨 Colors & Backgrounds
color: red | #ff0000 | rgb(255,0,0) | hsl(0,100%,50%)
background-color: blue | #0066cc
background-image: url('image.jpg') | linear-gradient(45deg, red, blue)
background-size: auto | cover | contain | 100px 200px
background-position: center | top left | 50% 50%
background-repeat: repeat | no-repeat | repeat-x | repeat-y
opacity: 1 | 0.5 | 0
πŸ“ Positioning
position: static | relative | absolute | fixed | sticky
top: auto | 0 | 10px | 50%
right: auto | 0 | 10px | 50%
bottom: auto | 0 | 10px | 50%
left: auto | 0 | 10px | 50%
z-index: auto | 0 | 1 | 999
float: none | left | right
clear: none | left | right | both
⬜ Borders & Spacing
margin: 0 | 10px | 1rem | 10px 20px | auto
padding: 0 | 10px | 1rem | 10px 20px
border: 1px solid black | 2px dashed red
border-radius: 0 | 5px | 50% | 10px 20px
border-width: thin | medium | thick | 1px
border-style: none | solid | dashed | dotted | double
border-color: transparent | red | #333
outline: none | 2px solid blue
✨ Animations & Transitions
transition: all 0.3s ease | opacity 1s linear
transition-property: all | opacity | transform
transition-duration: 0.3s | 500ms | 1s
transition-timing-function: ease | linear | ease-in-out
animation: slide 2s infinite | fade 1s ease-in-out
animation-name: slideIn | fadeOut
animation-duration: 2s | 500ms
animation-iteration-count: 1 | infinite | 3
/* Keyframe Example */
@keyframes slideIn {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}
πŸ”„ Transform & Effects
transform: rotate(45deg) | scale(1.2) | translateX(10px)
transform-origin: center | top left | 50% 50%
box-shadow: 0 2px 4px rgba(0,0,0,0.1) | inset 0 0 5px #333
text-shadow: 1px 1px 2px rgba(0,0,0,0.5)
filter: blur(5px) | brightness(1.2) | contrast(1.5)
clip-path: circle(50%) | polygon(0 0, 100% 0, 50% 100%)
🎭 Pseudo Classes & Elements
:hover /* Mouse over */
:focus /* Element focused */
:active /* Element being clicked */
:first-child /* First child element */
:last-child /* Last child element */
:nth-child(n) /* nth child (2n, odd, even) */
::before /* Insert content before */
::after /* Insert content after */
::first-line /* First line of text */
::placeholder /* Input placeholder */
πŸ“± Media Queries
@media screen and (max-width: 768px) {
  /* Mobile styles */
  .container { width: 100%; }
}
@media screen and (min-width: 769px) and (max-width: 1024px) {
  /* Tablet styles */
}
/* Common Breakpoints */
Mobile: max-width: 768px
Tablet: 769px - 1024px
Desktop: min-width: 1025px
πŸ“ CSS Units
px - Pixels (absolute)
% - Percentage (relative to parent)
em - Relative to parent font size
rem - Relative to root font size
vw - Viewport width (1vw = 1% of viewport)
vh - Viewport height (1vh = 1% of viewport)
vmin - Smaller of vw or vh
vmax - Larger of vw or vh
fr - Fraction unit (for CSS Grid)
πŸ—οΈ Common CSS Patterns
Center Div
.center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
Flexbox Center
.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}
Responsive Grid
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}
Sticky Header
.sticky-header {
  position: sticky;
  top: 0;
  z-index: 100;
}

CSS Cheat Sheet - Complete CSS Reference Guide & Properties

Introduction

In the world of web development, CSS (Cascading Style Sheets) is the secret ingredient that makes websites look modern, stylish, and user-friendly. While HTML provides the structure of a web page, CSS brings it to life with colors, layouts, animations, and responsiveness. For beginners and professionals alike, having a CSS Cheat Sheet - Complete CSS Reference Guide & Properties is extremely helpful. It acts like a quick handbook where you can easily find important CSS rules, selectors, and properties without memorizing everything.

This article will serve as your complete CSS cheat sheet, explaining the most important CSS properties, their uses, benefits, and some expert tips to master them. Whether you are just starting with CSS or looking for a consolidated reference, this guide will help you boost your front-end development skills.

What is CSS?

CSS stands for Cascading Style Sheets. It is a styling language used to control the presentation of web pages. With CSS, you can change:

  • Fonts and text styles
  • Backgrounds and colors
  • Layouts and positioning
  • Spacing (margins, padding)
  • Animations and transitions
  • Responsive design for all devices

Simply put, CSS separates design from structure, making websites clean, maintainable, and visually appealing.

Why Do You Need a CSS Cheat Sheet?

Memorizing all CSS properties can be overwhelming. A CSS Cheat Sheet - Complete CSS Reference Guide & Properties saves time and increases productivity.

Benefits of using a CSS cheat sheet:

  • Quick access to commonly used properties
  • Faster development workflow
  • Helps beginners learn by example
  • Useful for interviews and exams
  • Reduces errors and inconsistencies

Think of it as your pocket reference for web design.

CSS Basics You Must Know

Before diving into the complete reference, let’s revisit some basic CSS concepts.

1. CSS Syntax

Every CSS rule has the following structure:

selector {
  property: value;
}
  • Selector: The HTML element you want to style
  • Property: The style attribute you want to change
  • Value: The setting for that property

Example:

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

This makes all <h1> headings blue and sets their font size to 24px.

2. Ways to Add CSS

There are three main ways to use CSS in a web project:

  • Inline CSS: Applied directly to an HTML element using the style attribute
  • Internal CSS: Written inside a <style> tag within the HTML <head>
  • External CSS: Stored in a separate .css file and linked to the HTML

External CSS is the most preferred method as it keeps code organized.

3. Types of CSS Selectors

Selectors define which HTML elements are styled. Some common types:

  • Universal Selector (*) β†’ applies to all elements
  • Element Selector (h1, p) β†’ targets specific elements
  • Class Selector (.className) β†’ targets elements with a specific class
  • ID Selector (#idName) β†’ targets an element with a specific ID
  • Group Selector (h1, h2, p) β†’ applies to multiple elements
  • Pseudo-classes (:hover, :first-child) β†’ style elements in specific states

CSS Cheat Sheet - Complete Reference Guide & Properties

Here’s a comprehensive list of important CSS properties divided into categories.

1. Text & Font Properties

  • color – Sets text color
  • font-size – Defines font size
  • font-family – Chooses font type
  • font-weight – Boldness (normal, bold, lighter)
  • text-align – Aligns text (left, center, right, justify)
  • text-decoration – Underline, overline, or none
  • line-height – Adjusts spacing between lines

2. Background Properties

  • background-color – Sets background color
  • background-image – Adds image background
  • background-repeat – Controls repetition (repeat, no-repeat)
  • background-size – Scales background (cover, contain)
  • background-position – Positions background image

3. Box Model Properties

  • margin – Space outside an element
  • padding – Space inside an element
  • border – Adds border around element
  • width / height – Dimensions of element
  • box-sizing – Defines how size is calculated (content-box, border-box)

4. Positioning & Display

  • position – (static, relative, absolute, fixed, sticky)
  • top, left, right, bottom – Offsets for positioned elements
  • display – (block, inline, inline-block, flex, grid, none)
  • z-index – Stack order of elements
  • float – Floats element (left, right, none)

5. Flexbox Properties

  • display: flex; – Enables flexbox
  • justify-content – Aligns items horizontally (flex-start, center, space-between)
  • align-items – Aligns items vertically (stretch, center)
  • flex-direction – Row or column layout
  • flex-wrap – Allows wrapping of items

6. Grid Properties

  • display: grid; – Enables CSS grid
  • grid-template-columns – Defines column layout
  • grid-template-rows – Defines row layout
  • gap – Space between grid items
  • grid-column / grid-row – Span across multiple cells

7. Color & Units

  • Colors: red, #ff0000, rgb(255,0,0), rgba(255,0,0,0.5)
  • Units: px, %, em, rem, vh, vw

8. Animations & Transitions

  • transition – Smooth changes between states
  • animation – Keyframe animations
  • @keyframes – Defines animation sequence
  • transform – Rotate, scale, skew, translate

Advantages of CSS Cheat Sheet

  • Speed: Quickly apply correct properties
  • Clarity: Easy-to-read structure for beginners
  • Efficiency: Reduces repetitive searching online
  • Learning Aid: Helps understand relationships between properties
  • SEO Benefits: Cleaner design = better user experience = improved rankings

Practical Uses of CSS Cheat Sheet

  • Web Design Projects: Apply consistent styles faster
  • Interview Preparation: Quick revision of core properties
  • Responsive Design: Reminder of media queries and units
  • Bug Fixing: Identify styling errors quickly
  • Teaching & Learning: Acts as a handy study guide

Frequently Asked Questions (FAQ)

What is a CSS Cheat Sheet?

A CSS Cheat Sheet is a quick reference guide containing commonly used CSS selectors, properties, and values to speed up development.

Do I need to memorize all CSS properties?

No. With a cheat sheet, you can easily look up properties instead of memorizing everything.

Is a CSS Cheat Sheet useful for advanced developers?

Absolutely. Even professionals use cheat sheets to save time and avoid mistakes.

Can a CSS Cheat Sheet improve SEO?

Indirectly yes. By helping developers create clean, responsive, and fast websites, it contributes to better SEO performance.

How often should I update my CSS knowledge?

Regularly. CSS evolves with new features like Flexbox, Grid, and CSS Variables, so staying updated is crucial.

Conclusion

Mastering CSS can feel overwhelming, but with the right tools, it becomes much easier. A CSS Cheat Sheet - Complete CSS Reference Guide & Properties works as a personal assistant for web developers, helping them write efficient and effective code without wasting time searching for syntax or properties.

Whether you are a beginner learning the basics or an expert optimizing a large-scale project, keeping a CSS cheat sheet handy will boost productivity and ensure your websites look polished and professional.

πŸ‘‰ Start applying these CSS properties today, experiment with layouts, and keep this guide bookmarked as your go-to resource.