SlideShare a Scribd company logo
4
Most read
6
Most read
8
Most read
IN A ROCKET
Learn front-end development at rocket speed
CSS CSS FUNDAMENTALS
Units
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
ABSOLUTE 

UNITS
RELATIVE 

UNITS
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
ABSOLUTE 

UNITS
px pixel
1/96 of 1 inch 

(96px = 1 inch)
pt point
1/72 of 1 inch 

(72pt = 1 inch)
pc pica 12pt = 1pc
mm millimeter 1cm = 10mm
cm centimeter 10mm = 1cm
in inch 2.54 cm = 1 inch
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
GOOD
PRACTICE
Pixels are bad for usability:

• they don't scale,

• they don't help other elements
to scale proportionally.
Use them only when you
really need an exact and
fixed size.
EXAMPLE
border: 1px solid #000;
AVOID PIXELS
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
ABSOLUTE 

UNITS
RELATIVE 

UNITS
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
RELATIVE 

UNITS
% Percentage Relative to the parent element’s 

value for that property.
em Em Relative to the current font-size of the element.
rem Root em Relative to the font-size of the root.
ch Character Relative to width of the "0".
vw Viewport width Relative to the width of viewport. 

1vw = 1/100 of the viewport’s width.
vh Viewport height Relative to the height of viewport. 

1vw = 1/100 of the viewport’s height.
vmin Smaller dimension 1vmin = 1/100 of viewport’s 

smaller dimension.
ex x-height Relative to the height of a lower-case x.
vmax Larger dimension 1vmax = 1/100 of viewport’s 

larger dimension.
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
RELATIVE UNITS / PERCENTAGE
.box { width: 50%; }
container: 1000x
Box
500px
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
RELATIVE UNITS / EM
.box {
font-size: 2em;
width: 4em;
}
font-size: 20px
Box
20x4
Container text.
20x2
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
RELATIVE UNITS / REM
:root { font-size: 15px; }
.box {
font-size: 3rem;
width: 6rem;
}
font-size: 20px
Box
15x6
Container text.
15x3
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
RELATIVE UNITS / REM vs EM
EM REM
html {font-size: 100%} /* 16px */
h1 {
font-size: 2em;
margin-bottom: 1em;
}
p {
font-size: 1em;
margin-bottom: 1em;
}
/* 1em = 16px */
/* 1em = 32px */
/* 1em = 16px */
/* 1em = 16px */
html {font-size: 100%} /* 16px */
h1 {
font-size: 2rem;
margin-bottom: 1rem;
}
p {
font-size: 1rem;
margin-bottom: 1rem;
}
/* 1em = 16px */
/* 1em = 16px */
/* 1em = 16px */
/* 1em = 16px */
[
[
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
RELATIVE UNITS / VW
.box {
width: 50vw;
}
viewport
Box
50% of the viewport
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
RELATIVE UNITS / VH
.box {
height: 100vh;
}
viewport
Box
100% of the viewport
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
RELATIVE UNITS / VMIN
.box {
font-size: 10vmin;
}
width: 1000px
Box 10% of 500px=50px
1vmin = 1vw or 1vh, whichever is smaller.
height: 500px
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
RELATIVE UNITS / VMAX
.box {
font-size: 10vmax;
}
width: 1000px
Box
1vmax = 1vw or 1vh, whichever is larger.
height: 500px
10% of 1000px=100px
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
HOW TO CHOOSE A CSS UNIT
Do I need to scale an element when
the viewport size changes?
What do I want it to scale relative to?
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
ABSOLUTE 

UNITS
RELATIVE 

UNITS
CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com
TOOLS: TYPE SCALE
Learn front-end development at rocket speed
inarocket.com
by miguelsanchez.com
YOU CAN CONTINUE THIS COURSE FOR FREE ON
+ READY TO USE CODE
+ QUIZZES
+ FREE UPDATES
We respect your time

No more blah blah videos. Just straight to
the point slides with relevant information.
Ready to use code

Real code you can just copy and paste into
your real projects.
Step by step guides

Clear and concise steps to build real use
solutions. No missed points.
Learn front-end development at rocket speed
inarocket.com
IN A ROCKET
Learn front-end development at rocket speed
CSS CSS FUNDAMENTALS
Units

More Related Content

Similar to 17- Learn CSS Fundamentals / Units (20)

PDF
Intro to @viewport & other new Responsive Web Design CSS features
Andreas Bovens
 
PDF
Squishy pixels
FITC
 
PPTX
Spectrum 16 pmc 16 - preparing legacy projects for responsive design
Neil Perlin
 
PDF
Responsive Web Design e a Ubiquidade da Web
Eduardo Shiota Yasuda
 
PDF
Accelerated Stylesheets
Wynn Netherland
 
PDF
Web Layout
Shawn Calvert
 
PDF
Fewd week3 slides
William Myers
 
PDF
01 Introduction To CSS
crgwbr
 
PPTX
Css methods architecture
Lasha Sumbadze
 
PDF
Responsive web design
Ben MacNeill
 
PDF
Build your own CDN with Varnish - Confoo 2022
Thijs Feryn
 
KEY
CSS Frameworks
Web Directions
 
PDF
Html frames
eShikshak
 
PDF
Intro to CSS
Randy Oest II
 
PPTX
esponsive web design means that your website (
vishal choudhary
 
PDF
Front End Best Practices
Holger Bartel
 
KEY
card flip
slidesharepimp
 
PDF
Introduction to Responsive Design v.2
Clarissa Peterson
 
PDF
intro-to-fluent-tutorial-tutiafflen24.pdf
VAIBHAVBANSODE10
 
PPT
Advance Css 1194323118268797 5
dharshyamal
 
Intro to @viewport & other new Responsive Web Design CSS features
Andreas Bovens
 
Squishy pixels
FITC
 
Spectrum 16 pmc 16 - preparing legacy projects for responsive design
Neil Perlin
 
Responsive Web Design e a Ubiquidade da Web
Eduardo Shiota Yasuda
 
Accelerated Stylesheets
Wynn Netherland
 
Web Layout
Shawn Calvert
 
Fewd week3 slides
William Myers
 
01 Introduction To CSS
crgwbr
 
Css methods architecture
Lasha Sumbadze
 
Responsive web design
Ben MacNeill
 
Build your own CDN with Varnish - Confoo 2022
Thijs Feryn
 
CSS Frameworks
Web Directions
 
Html frames
eShikshak
 
Intro to CSS
Randy Oest II
 
esponsive web design means that your website (
vishal choudhary
 
Front End Best Practices
Holger Bartel
 
card flip
slidesharepimp
 
Introduction to Responsive Design v.2
Clarissa Peterson
 
intro-to-fluent-tutorial-tutiafflen24.pdf
VAIBHAVBANSODE10
 
Advance Css 1194323118268797 5
dharshyamal
 

More from In a Rocket (15)

PDF
3- Learn Flexbox & CSS Grid / Container & items
In a Rocket
 
PDF
2- Learn Flexbox & CSS Grid / Context
In a Rocket
 
PDF
1- Learn Flexbox & CSS Grid / Environment setup
In a Rocket
 
PDF
15- Learn CSS Fundamentals / Color
In a Rocket
 
PDF
14- Learn CSS Fundamentals / Inheritance
In a Rocket
 
PDF
13- Learn CSS Fundamentals / Specificity
In a Rocket
 
PDF
12- Learn CSS Fundamentals / Mix & group
In a Rocket
 
PDF
11- Learn CSS Fundamentals / Combinators
In a Rocket
 
PDF
10- Learn CSS Fundamentals / Pseudo-elements
In a Rocket
 
PDF
9- Learn CSS Fundamentals / Pseudo-classes
In a Rocket
 
PDF
8- Learn CSS Fundamentals / Attribute selectors
In a Rocket
 
PDF
2- Learn HTML Fundamentals / Text Formatting
In a Rocket
 
PDF
1- Learn HTML Fundamentals / Start in 5 Minutes
In a Rocket
 
PDF
Learn SUIT: CSS Naming Convention
In a Rocket
 
PDF
Learn BEM: CSS Naming Convention
In a Rocket
 
3- Learn Flexbox & CSS Grid / Container & items
In a Rocket
 
2- Learn Flexbox & CSS Grid / Context
In a Rocket
 
1- Learn Flexbox & CSS Grid / Environment setup
In a Rocket
 
15- Learn CSS Fundamentals / Color
In a Rocket
 
14- Learn CSS Fundamentals / Inheritance
In a Rocket
 
13- Learn CSS Fundamentals / Specificity
In a Rocket
 
12- Learn CSS Fundamentals / Mix & group
In a Rocket
 
11- Learn CSS Fundamentals / Combinators
In a Rocket
 
10- Learn CSS Fundamentals / Pseudo-elements
In a Rocket
 
9- Learn CSS Fundamentals / Pseudo-classes
In a Rocket
 
8- Learn CSS Fundamentals / Attribute selectors
In a Rocket
 
2- Learn HTML Fundamentals / Text Formatting
In a Rocket
 
1- Learn HTML Fundamentals / Start in 5 Minutes
In a Rocket
 
Learn SUIT: CSS Naming Convention
In a Rocket
 
Learn BEM: CSS Naming Convention
In a Rocket
 
Ad

Recently uploaded (20)

PPTX
The ARUBA Kind of new Proposal Umum .pptx
andiwarneri
 
PDF
03 Internal Analysis Strategik Manajemen.pdf
AhmadRifaldhi
 
PPTX
My Mother At 66! (2).pptx00000000000000000000000000000
vedapattisiddharth
 
PPTX
BitRecover OST to PST Converter Software
antoniogosling01
 
PDF
The Convergence of Threat Behaviors Across Intrusions
Joe Slowik
 
PDF
Materi tentang From Digital Economy to Fintech.pdf
Abdul Hakim
 
PDF
B M Mostofa Kamal Al-Azad [Document & Localization Expert]
Mostofa Kamal Al-Azad
 
PDF
web application development company in bangalore.pdf
https://dkpractice.co.in/seo.html tech
 
PDF
ContextForge MCP Gateway - the missing proxy for AI Agents and Tools
Mihai Criveti
 
PPT
Almos Entirely Correct Mixing with Apps to Voting
gapati2964
 
PPTX
Q1 English3 Week5 [email protected]
JenniferCawaling1
 
PPTX
原版一样(ISM毕业证书)德国多特蒙德国际管理学院毕业证多少钱
taqyed
 
PDF
Transmission Control Protocol (TCP) and Starlink
APNIC
 
PDF
I Want to join occult brotherhood for money ritual#((+2347089754903))
haragonoccult
 
PPTX
Lesson 1.1 Career-Opportunities-in-Ict.pptx
lizelgumadlas1
 
PPTX
原版一样(ANU毕业证书)澳洲澳大利亚国立大学毕业证在线购买
Taqyea
 
PDF
Beginning-Laravel-Build-Websites-with-Laravel-5.8-by-Sanjib-Sinha-z-lib.org.pdf
TagumLibuganonRiverB
 
PDF
Clive Dickens RedTech Public Copy - Collaborate or Die
Clive Dickens
 
PDF
Slides: Eco Economic Epochs for The World Game (s) pdf
Steven McGee
 
PPTX
Class_4_Limbgvchgchgchgchgchgcjhgchgcnked_Lists.pptx
test123n
 
The ARUBA Kind of new Proposal Umum .pptx
andiwarneri
 
03 Internal Analysis Strategik Manajemen.pdf
AhmadRifaldhi
 
My Mother At 66! (2).pptx00000000000000000000000000000
vedapattisiddharth
 
BitRecover OST to PST Converter Software
antoniogosling01
 
The Convergence of Threat Behaviors Across Intrusions
Joe Slowik
 
Materi tentang From Digital Economy to Fintech.pdf
Abdul Hakim
 
B M Mostofa Kamal Al-Azad [Document & Localization Expert]
Mostofa Kamal Al-Azad
 
web application development company in bangalore.pdf
https://dkpractice.co.in/seo.html tech
 
ContextForge MCP Gateway - the missing proxy for AI Agents and Tools
Mihai Criveti
 
Almos Entirely Correct Mixing with Apps to Voting
gapati2964
 
原版一样(ISM毕业证书)德国多特蒙德国际管理学院毕业证多少钱
taqyed
 
Transmission Control Protocol (TCP) and Starlink
APNIC
 
I Want to join occult brotherhood for money ritual#((+2347089754903))
haragonoccult
 
Lesson 1.1 Career-Opportunities-in-Ict.pptx
lizelgumadlas1
 
原版一样(ANU毕业证书)澳洲澳大利亚国立大学毕业证在线购买
Taqyea
 
Beginning-Laravel-Build-Websites-with-Laravel-5.8-by-Sanjib-Sinha-z-lib.org.pdf
TagumLibuganonRiverB
 
Clive Dickens RedTech Public Copy - Collaborate or Die
Clive Dickens
 
Slides: Eco Economic Epochs for The World Game (s) pdf
Steven McGee
 
Class_4_Limbgvchgchgchgchgchgcjhgchgcnked_Lists.pptx
test123n
 
Ad

17- Learn CSS Fundamentals / Units

  • 1. IN A ROCKET Learn front-end development at rocket speed CSS CSS FUNDAMENTALS Units
  • 2. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com ABSOLUTE 
 UNITS RELATIVE 
 UNITS
  • 3. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com ABSOLUTE 
 UNITS px pixel 1/96 of 1 inch (96px = 1 inch) pt point 1/72 of 1 inch (72pt = 1 inch) pc pica 12pt = 1pc mm millimeter 1cm = 10mm cm centimeter 10mm = 1cm in inch 2.54 cm = 1 inch
  • 4. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com GOOD PRACTICE Pixels are bad for usability: • they don't scale, • they don't help other elements to scale proportionally. Use them only when you really need an exact and fixed size. EXAMPLE border: 1px solid #000; AVOID PIXELS
  • 5. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com ABSOLUTE 
 UNITS RELATIVE 
 UNITS
  • 6. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com RELATIVE 
 UNITS % Percentage Relative to the parent element’s value for that property. em Em Relative to the current font-size of the element. rem Root em Relative to the font-size of the root. ch Character Relative to width of the "0". vw Viewport width Relative to the width of viewport. 1vw = 1/100 of the viewport’s width. vh Viewport height Relative to the height of viewport. 1vw = 1/100 of the viewport’s height. vmin Smaller dimension 1vmin = 1/100 of viewport’s smaller dimension. ex x-height Relative to the height of a lower-case x. vmax Larger dimension 1vmax = 1/100 of viewport’s larger dimension.
  • 7. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com RELATIVE UNITS / PERCENTAGE .box { width: 50%; } container: 1000x Box 500px
  • 8. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com RELATIVE UNITS / EM .box { font-size: 2em; width: 4em; } font-size: 20px Box 20x4 Container text. 20x2
  • 9. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com RELATIVE UNITS / REM :root { font-size: 15px; } .box { font-size: 3rem; width: 6rem; } font-size: 20px Box 15x6 Container text. 15x3
  • 10. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com RELATIVE UNITS / REM vs EM EM REM html {font-size: 100%} /* 16px */ h1 { font-size: 2em; margin-bottom: 1em; } p { font-size: 1em; margin-bottom: 1em; } /* 1em = 16px */ /* 1em = 32px */ /* 1em = 16px */ /* 1em = 16px */ html {font-size: 100%} /* 16px */ h1 { font-size: 2rem; margin-bottom: 1rem; } p { font-size: 1rem; margin-bottom: 1rem; } /* 1em = 16px */ /* 1em = 16px */ /* 1em = 16px */ /* 1em = 16px */ [ [
  • 11. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com RELATIVE UNITS / VW .box { width: 50vw; } viewport Box 50% of the viewport
  • 12. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com RELATIVE UNITS / VH .box { height: 100vh; } viewport Box 100% of the viewport
  • 13. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com RELATIVE UNITS / VMIN .box { font-size: 10vmin; } width: 1000px Box 10% of 500px=50px 1vmin = 1vw or 1vh, whichever is smaller. height: 500px
  • 14. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com RELATIVE UNITS / VMAX .box { font-size: 10vmax; } width: 1000px Box 1vmax = 1vw or 1vh, whichever is larger. height: 500px 10% of 1000px=100px
  • 15. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com HOW TO CHOOSE A CSS UNIT Do I need to scale an element when the viewport size changes? What do I want it to scale relative to?
  • 16. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com ABSOLUTE 
 UNITS RELATIVE 
 UNITS
  • 17. CSS FUNDAMENTALS: Build a strong foundation by solving real cases inarocket.com TOOLS: TYPE SCALE
  • 18. Learn front-end development at rocket speed inarocket.com by miguelsanchez.com YOU CAN CONTINUE THIS COURSE FOR FREE ON + READY TO USE CODE + QUIZZES + FREE UPDATES
  • 19. We respect your time
 No more blah blah videos. Just straight to the point slides with relevant information. Ready to use code
 Real code you can just copy and paste into your real projects. Step by step guides
 Clear and concise steps to build real use solutions. No missed points. Learn front-end development at rocket speed inarocket.com
  • 20. IN A ROCKET Learn front-end development at rocket speed CSS CSS FUNDAMENTALS Units