Professional Documents
Culture Documents
CSS Cheatsheet Withlinks Compressed
CSS Cheatsheet Withlinks Compressed
Cascading
Style Sheets
Connect with Alumni
CSS (Cascading Style Sheet)
CSS (Cascading Style Sheets) is a language for styling web pages, controlling
layout, and enhancing visual presentation.
Types of CSS
Internal CSS
Internal CSS is
styling defined
within the HTML
document's <style>
tag in the <head>
02 CSS Cheatsheet
2 Selectors
Common Selectors
HTML Code
Class Selector
Syntax .classname{...}
Usecase
Code
Before applying
After applying
03 CSS Cheatsheet
Element Selector
Syntax elementname{...}
Usecase
Code
Before applying
After applying
Pseudo Selector
Syntax selector::pseudo-class{...}
Usecase
Code
Before applying
After applying
04 CSS Cheatsheet
Advanced Selectors
HTML Code
Child Combinator(>)
Usecase
Code
Before applying
After applying
05 CSS Cheatsheet
Adjacent Sibling Combinator (+)
Syntax element1+element2{...}
Usecase
Code
Before applying
After applying
Usecase
Code
Before applying
After applying
06 CSS Cheatsheet
Basic Selectors
Advanced Selectors
07 CSS Cheatsheet
3 Common Properties
Color Property
Usecase
Color Example
Code
Before applying
Color Example
After applying
08 CSS Cheatsheet
Border Property
Usecase
Code
Before applying
After applying
09 CSS Cheatsheet
Gradient Property
Usecase
Code
Before applying
After applying
Syntax font-family:...;
Usecase
Code
Before applying
After applying
10 CSS Cheatsheet
4 Units In CSS
Example
100 px A
2em A
2 ch A
2 rem A
50 vw A
20 vmin A
10 vmax A
50 % A
calc(10vw - 100px) A
11 CSS Cheatsheet
5 CSS Box Model
Property Description
Content The actual content of the box, where text and images appear.
Width Total width of the box, including content, padding, and border
Height Total height of the box, including content, padding, and border
Box-Sizing Defines how the width and height of an element are calculated.
Scaler
Padding creates space between
content and border.
Width
Border visually separates elements.
Margin provides spacing outside
elements, affecting layout.
12 CSS Cheatsheet
6 CSS Variables
CSS variables declared at the root level or within Locally scoped CSS variables, defined within a
the :root selector have a global scope, accessible specific selector or rule set, are accessible only
throughout the entire stylesheet. within that scope and its descendant elements,
providing more granular control over styling.
7 Filters in CSS
Filter Description
13 CSS Cheatsheet
grayscale() Converts an element to grayscale.
Example
How to use
14 CSS Cheatsheet
8 CSS Layout And Positioning
15 CSS Cheatsheet
CSS Positioning
Relative Absolute
Relative to
its original Relative to
position parentʼs body.
Fixed Sticky
Remains at same
scroll
place even on scroll.
CSS Display
None
16 CSS Cheatsheet
9 Responsive Design in CSS
Examples
HTML Content
@media screen and
(min-width 1024 px)
{...}
MEDIA
QUERIES @media screen and
(min-width 768 px) and
(max-width: 1023px)
{...}
17 CSS Cheatsheet
10 Flexbox in CSS
Flex Container
Property Usage
Flex-Direction Flex-Wrap
Sets how the flex items are placed inside the container. Tells the container whether to wrap the items or not
1 2 3 1 3 1 2 3 4
wrap wrap-reverse
2 2
row-reverse
1 2 3 4
3 2 1 3 1
3 4 2 1
18 CSS Cheatsheet
Justify-Content Align-Content
Tells the container how to align items horizontally. Tells the container how to align items vertically.
flex-start
flex-start flex-end
1 2 3
1 2 3
flex-end
1 2 3
1 2 3
1 2 3
1 2 3 1 2 3
space-between
1 2 3
Terminology
flex-container
flex item
main size
main axis
Flex Items
19 CSS Cheatsheet
Properties Usage
Flex-Basis Flex-Grow
Sets the main size of a flex item. Sets how much space should be taken up by the flex item.
250px 1
1 2 3 1 2 3
Flex-Shrink Align-Self
Sets how much should a flex item shrink relative to others Sets how individual items should be aligned
inside the container
0
1 2 3 flex-start flex-end
center stretch
Order
1 3 1 3
2 2
Sets the ordering of the complex items.
-1
3 2 1
1 2 3
20 CSS Cheatsheet
11 Transitions And Animations
Transitions Animations
Smooth changes in property values. Key-frame based animation effects.
transition-property @keyframes
transition-duration animation-name
transition-timing-function animation-duration
transition-delay animation-timing-function
animation-delay
animation-iteration-count
animation-direction
animation-fill-mode
animation-play-mode
0s 1s 2s 3s 4s
Time(in seconds)
Normal
Hovered
21 CSS Cheatsheet
Transitions Animations
A A
C
B
12 CSS Functions
22 CSS Cheatsheet
13 CSS Grids
Grid Container Defines a grid container to hold grid items. display: grid;
Example
14 Transformations in CSS
2D Transformations Apply transformations in a 2D plane
23 CSS Cheatsheet
translate Moves an element along the X and Y axes transform: translate (20px,30px);
15 CSS 3 Features
box-shadow:
rgba {0,0,0,0,4}
10px 10px;
box-shadow:
rgba {0,0,0,0,4}
10px 10px;
inset
24 CSS Cheatsheet
box-shadow:
rgba {0,0,0,0,4}
10px 10px 0
10px /* spread */
box-shadow:
rgba {0,0,0,0,4}
10px 10px 0
10px /* spread */
inset
Selector Specificity: Understand the hierarchy of CSS selectors to ensure proper application
of styles.
Box Model: Master the concept of content, padding, border, and margin to effectively
control element layout.
Responsive Design: Implement media queries to create designs that adapt seamlessly across
different devices and screen sizes.
Cross-Browser
Compatibility: Test and ensure that CSS styles render consistently across various web
browsers for a uniform user experience.
CSS Preprocessors: Utilize tools like Sass or Less to streamline CSS development by enabling
features like variables, mixins, and nested rules.
25 CSS Cheatsheet