I’ll make you a CSS Complete Cheat Sheet that’s easy to revise but still deep enough for real project use.
I’ll break it into sections with tables, diagrams, and examples so you can keep it as a ready reference.


📄 CSS Complete Cheat Sheet


1. CSS Basics

FeatureDescriptionExample
Full formCascading Style Sheets
PurposeControls look & layout of HTML elements
Syntaxselector { property: value; }p { color: red; }

2. Types of CSS

TypeWhere AppliedExampleUse Case
InlineIn style attribute of HTML tag<p style="color:red;">Quick test or single change
InternalInside <style> in <head><style>p{color:red;}</style>Page-specific styles
ExternalLinked .css file<link rel="stylesheet" href="style.css">Large sites, reusability

3. CSS Selectors

Basic

p { color: red; }     /* Tag */
.myClass { color: red; } /* Class */
#myId { color: red; }    /* ID */

Combinators

div p { }    /* Descendant */
div > p { }  /* Direct child */
h1 + p { }   /* Adjacent sibling */
h1 ~ p { }   /* General sibling */

Attribute

input[type="text"] { }
a[href^="https"] { }
img[src$=".jpg"] { }

Pseudo-classes

a:hover { color: red; }
input:focus { border: 1px solid blue; }

Pseudo-elements

p::first-letter { font-size: 2em; }
p::after { content: "✓"; }

4. CSS Units

TypeUnitMeaning
Absolutepx, pt, cm, mm, inFixed size
Relative%% of parent
emRelative to parent font-size
remRelative to root font-size
vw, vhRelative to viewport width/height

5. Box Model

+-------------------------+
|       Margin            |
|  +-------------------+  |
|  |    Border         |  |
|  | +---------------+ |  |
|  | |  Padding      | |  |
|  | | +-----------+ | |  |
|  | | |  Content  | | |  |
|  | | +-----------+ | |  |
|  | +---------------+ |  |
|  +-------------------+  |
+-------------------------+

Properties:

margin: 10px;
padding: 20px;
border: 2px solid black;

6. Common CSS Properties

Text & Fonts

color: red;
font-family: Arial, sans-serif;
font-size: 16px;
font-weight: bold;
text-align: center;
text-decoration: underline;

Background

background-color: yellow;
background-image: url("bg.jpg");
background-repeat: no-repeat;
background-size: cover;

Borders

border: 2px solid black;
border-radius: 10px;

Layout

display: block | inline | flex | grid;
position: static | relative | absolute | fixed | sticky;
top: 10px; left: 20px;

7. Flexbox

PropertyPurposeExample
display: flex;Enable flexdisplay: flex;
justify-contentHorizontal alignmentcenter, space-between
align-itemsVertical alignmentcenter, flex-start
flex-wrapWrap itemswrap, nowrap

8. Grid

display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 10px;

9. Animation & Transition

transition: all 0.3s ease;

@keyframes slide {
  from { transform: translateX(0); }
  to { transform: translateX(100px); }
}

div {
  animation: slide 2s infinite;
}

10. Responsive Design

@media (max-width: 768px) {
  body { font-size: 14px; }
}

11. Best Practices

  • Use external CSS for large projects
  • Use classes for styling instead of IDs
  • Group related properties together
  • Comment complex sections
  • Use CSS variables for consistent colors/fonts
  • Minify CSS for performance

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *