SlideShare uma empresa Scribd logo
1 de 71
Baixar para ler offline
Intro to
CSS
Randy Oest
Manager of Digital Design
Williams Randall Marketing
!
@amazingrando
Why Learn CSS?
1. Running a blog on a CMS and
want to tweak things
2. Working with a developer and
want to understand how to talk
with them
3. Web designer looking to
understand how things get built
What We’ll Learn
1. What is CSS
2. How to speak CSS
3. How to apply it
4. Where to find out
more info
If HTML
is the
Skeleton
of Web
pages…
CSS is
the
muscle
and
skin.
CSS Needs HTML
CSS is used to style
elements, giving
them form.
HTML Elements
<p>Paragraph …</p>	
  
<div	
  class=“nav”>…</div>	
  
<h1	
  id=“title”>Headline</h1>	
  
CSS Needs HTML
Selectors
are used
to target
styles.
Examples of Selectors
<p>Paragraph …</p>	
  
p	
  {	
  …	
  }	
  
Examples of Selectors
<div	
  class=“nav”>…</div>	
  
.nav	
  {	
  …	
  }	
  
Classes
Class names always
start with a period.
.class
IDs
IDs always start 

with a hash.
There can only be one on a page.
#id
Think of classes as your name
and nicknames, e.g. Randy,
Amazing Rando, Hey You…
Think of IDs as your unique
social security or credit card
numbers.
Multiple Selectors
<h1	
  id=“title”>Headline</h1>	
  
h1#title	
  {	
  …	
  }	
  
No spaces!
Specificity
When there is a style
conflict, IDs trump
classes, and classes
trump HTML elements
Nested Elements
<div	
  id=“feature”>	
  
	
   <img	
  src=“…”	
  />	
  
	
   Some Text …
</div>
Nested Elements
<div	
  id=“feature”>	
  
	
   <img	
  src=“…”	
  />
#feature	
  img	
  {	
  …	
  }
Now there is a space.
.class	
  {	
  
	
   color:	
  #fff;	
  
	
   padding:	
  10px;	
  
}
Properties & Values
Property
Value
PX: Pixels
%: Percentage
EM: Relative unit, equal to
the current font size
Common Size Units
EMs, being relative
units, can get
complicated quickly
when you nest them.
Warning about EMs
1. External File
2. Internal, using the
<style> tag
3. Inline styles
Getting CSS into the HTML
Put this inside the <head>
<link	
  rel="stylesheet"	
  
href="file.css">
External File
Put this inside the <head>
<style	
  type="text/css">	
  
	
   …	
  your	
  styles	
  …	
  
</style>
Internal
<h1	
  style=“color:#fff;”>	
  
	
   Headline	
  
</h1>
Inline HTML
<interlude>
Obligatory
Baby Pictures
</interlude>
Box
Model
Elements of the Box
An element’s size is equal to:
Width (or Height)
+ Padding 

+ Border
+ Margin
= Total Size
The Box Model is Tricky
.box	
  {	
  
	
  width:	
  200px;	
  
	
  padding:	
  10px;	
  
	
  border:	
  5px;	
  
	
  margin:	
  15px;	
  
}
So if we plug in values:
Width (200px)
+ Padding (10px * 2 sides)

+ Border (5px * 2 sides)
+ Margin (15 px * 2 sides)
= Total Size (260px)
The Box Model is Tricky
There is a
Better Way
Use a
Different 

Box Model
*,	
  *:before,	
  *:after	
  {	
  
-­‐webkit-­‐box-­‐sizing:	
  border-­‐box;	
  
-­‐moz-­‐box-­‐sizing:	
  border-­‐box;	
  
box-­‐sizing:	
  border-­‐box;	
  
}
Magic Bullet
selector	
  {	
  
-­‐webkit-­‐box-­‐sizing:	
  border-­‐box;	
  
-­‐moz-­‐box-­‐sizing:	
  border-­‐box;	
  
box-­‐sizing:	
  border-­‐box;	
  
}
Fixing A Single Item
An element’s size
is equal to the
width size.
Border Box is NOT Tricky
Content-Box
(Default)
Border-Box
(Good!)
padding-­‐top:	
  10px;	
  
padding-­‐right:	
  5px;	
  
padding-­‐bottom:	
  10px;	
  
padding-­‐left:	
  5px;	
  
OR
padding:	
  10px	
  5px	
  10px	
  5px;
Shorthand
Starts at NOON 

and goes clockwise.
padding:	
  top	
  right	
  bottom	
  left;
Shorthand
padding:	
  top+bottom	
  right+left;	
  
padding:	
  10px	
  5px;
Even More Shorthand
The Display Property
Block:
<h1>,	
  <p>,	
  <div>	
  
Inline:
<a>,	
  <span>,	
  <b>,	
  <strong>
The Display Property
a	
  {	
  
	
  display:	
  block;	
  
}	
  
The Display Property
There are many more
exotic display types, such
as inline-­‐block, none, etc.
The Display Property
Flow
Floats
img	
  {	
  
	
  float:	
  left;	
  
}	
  
The Display Property
Positioning can
change an element
in the flow.
Positioning
Parent
Element
position:	
  static
img	
  {	
  
	
  position:	
  static;	
  
}	
  
Positioning
This is the default, no need to write it
Positioning
Parent
Element
position:	
  fixed
Fixed in relation
to the browser.
img	
  {	
  
	
  position:	
  fixed;	
  
	
  top:	
  0px;	
  	
  
	
  left:	
  0px;	
  
}	
  
Positioning
top:	
  0px;	
  	
  
right:	
  0px;	
  
bottom:	
  0px;	
  
left:	
  0px;	
  
Positioning
Positioning
Parent
Element
position:	
  relative
img	
  {	
  
	
  position:	
  relative;	
  
	
  top:	
  -­‐10px;	
  	
  
	
  left:	
  -­‐200px;	
  
}	
  
Positioning
Positioning
Parent
Element
position:	
  absolute
position:	
  static
img	
  {	
  
	
  position:	
  absolute;	
  
	
  top:	
  0px;	
  	
  
	
  left:	
  0px;	
  
}	
  
Positioning
Absolute positioning
looks for the parent
with a position other
than static.
Positioning
Positioning
Parent
Element
position:	
  absolute
position:	
  relative
img	
  {	
  
	
  position:	
  absolute;	
  
	
  top:	
  0px;	
  	
  
	
  left:	
  0px;	
  
}	
  
Positioning
A Quick Note
About Mobile
Most CSS that you
write for mobile is
just CSS.
Percentages and
relative units, like EMs
are better than pixels,
which are static width.
@media	
  all	
  and	
  (max-­‐width:	
  699px){	
  
	
   …	
  styles	
  
}
Media Query
Further Learning
RandyOest.com/CSS

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Web front end development introduction to html css and javascript
Web front end development introduction to html css and javascriptWeb front end development introduction to html css and javascript
Web front end development introduction to html css and javascript
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02
 
Html Expression Web
Html Expression WebHtml Expression Web
Html Expression Web
 
Html and css
Html and cssHtml and css
Html and css
 
HTML and CSS crash course!
HTML and CSS crash course!HTML and CSS crash course!
HTML and CSS crash course!
 
CSS
CSSCSS
CSS
 
Css
CssCss
Css
 
Web Development Basics: HOW TO in HTML
Web Development Basics: HOW TO in HTMLWeb Development Basics: HOW TO in HTML
Web Development Basics: HOW TO in HTML
 
CSS
CSSCSS
CSS
 
Css ppt
Css pptCss ppt
Css ppt
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
 
Cascading style sheets - CSS
Cascading style sheets - CSSCascading style sheets - CSS
Cascading style sheets - CSS
 
Css types internal, external and inline (1)
Css types internal, external and inline (1)Css types internal, external and inline (1)
Css types internal, external and inline (1)
 
Web Design Course: CSS lecture 4
Web Design Course: CSS  lecture 4Web Design Course: CSS  lecture 4
Web Design Course: CSS lecture 4
 
Fundamental CSS3
Fundamental CSS3Fundamental CSS3
Fundamental CSS3
 
(Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS (Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS
 
Html & CSS - Best practices 2-hour-workshop
Html & CSS - Best practices 2-hour-workshopHtml & CSS - Best practices 2-hour-workshop
Html & CSS - Best practices 2-hour-workshop
 
Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 

Semelhante a Intro to CSS

GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1
Heather Rock
 
CSS Foundations, pt 2
CSS Foundations, pt 2CSS Foundations, pt 2
CSS Foundations, pt 2
Shawn Calvert
 
Html css crash course may 11th, atlanta
Html css crash course may 11th, atlantaHtml css crash course may 11th, atlanta
Html css crash course may 11th, atlanta
Thinkful
 
01 Introduction To CSS
01 Introduction To CSS01 Introduction To CSS
01 Introduction To CSS
crgwbr
 
Code &amp; design your first website (3:16)
Code &amp; design your first website (3:16)Code &amp; design your first website (3:16)
Code &amp; design your first website (3:16)
Thinkful
 

Semelhante a Intro to CSS (20)

Css
CssCss
Css
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
 
CSS
CSSCSS
CSS
 
CSS Foundations, pt 2
CSS Foundations, pt 2CSS Foundations, pt 2
CSS Foundations, pt 2
 
Css, xhtml, javascript
Css, xhtml, javascriptCss, xhtml, javascript
Css, xhtml, javascript
 
Html css crash course may 11th, atlanta
Html css crash course may 11th, atlantaHtml css crash course may 11th, atlanta
Html css crash course may 11th, atlanta
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
 
Lecture-7.pptx
Lecture-7.pptxLecture-7.pptx
Lecture-7.pptx
 
HTML+CSS: how to get started
HTML+CSS: how to get startedHTML+CSS: how to get started
HTML+CSS: how to get started
 
Designing for the web - 101
Designing for the web - 101Designing for the web - 101
Designing for the web - 101
 
Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01
 
01 Introduction To CSS
01 Introduction To CSS01 Introduction To CSS
01 Introduction To CSS
 
CSS 101
CSS 101CSS 101
CSS 101
 
css v1 guru
css v1 gurucss v1 guru
css v1 guru
 
Css Founder.com | Cssfounder Org
Css Founder.com | Cssfounder OrgCss Founder.com | Cssfounder Org
Css Founder.com | Cssfounder Org
 
Website designing company | Cssfounder.com
Website designing company | Cssfounder.comWebsite designing company | Cssfounder.com
Website designing company | Cssfounder.com
 
Day of code
Day of codeDay of code
Day of code
 
Code &amp; design your first website (3:16)
Code &amp; design your first website (3:16)Code &amp; design your first website (3:16)
Code &amp; design your first website (3:16)
 

Mais de Randy Oest II (7)

A Modern Designer's Workflow
A Modern Designer's WorkflowA Modern Designer's Workflow
A Modern Designer's Workflow
 
Making Great Display Ads
Making Great Display AdsMaking Great Display Ads
Making Great Display Ads
 
Designing for developers
Designing for developersDesigning for developers
Designing for developers
 
Intro to HTML
Intro to HTMLIntro to HTML
Intro to HTML
 
Email design
Email designEmail design
Email design
 
What design has taught my life
What design has taught my lifeWhat design has taught my life
What design has taught my life
 
LESS is MOAR
LESS is MOARLESS is MOAR
LESS is MOAR
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

Intro to CSS