SlideShare a Scribd company logo
1 of 33
CSS Overview
You know what CSS is: CASCADING STYLE SHEETS.
Styling of HTML elements VIA standard rules.
Important Topics
1. CSS Syntax / Selectors
2. Including CSS Rules
3. CSS Box Model
4. Floating/Clearing
Effectively
5. Positioning
6. Use of “!important”
declaration
7. Responsive
Considerations
Elements, IDs, Classes
ID (#foo {prop: set;})
One instance per page (usually).
Class (.foo {prop: set;})
Multiple instances per page (often).
HTML Element (foo {prop: set;})
Vague! But powerful!
Specificity in Selectors
Show “lineage” of element
(#wrapper #content .cool)
Build with effective use of
IDs and classes site-wide.
Pseudo-selectors: don’t rely
on them too much.
Ways to Include Rules
External Stylesheet
(Preferred!)
<style> Tag
(Helpful! But not portable!)
Inline style=“” attribute
(Powerful! But messy!)
<link> to External Styles
Remember position in DOM; later rules will
overwrite earlier rules
Allows you to keep styles isolated (forms, etc.)
and allows portability of styles
Makes site-wide styling edits easy!
Easy to reference in Chrome Developer Tools
<style> Tags
Useful for single-page styles
Hacky solution for weirdo CMSes
(hiding elements that you need to
hide, etc.)
Not portable, but lets you target
multiple elements on the same
page VIA IDs, classes, and HTML
elements.
Happy friday
Inline style=“” Attributes
Browser gives style=“” attributes most priority.
Ve r y p o w e r f u l ! !
Must be manually replicated; not portable!
Makes HTML messy
Useful for JavaScript stuff
More on Specificity…
Depending on ordering in DOM
and degree of specificity of rule
declarations, the more specific
rule will override another.
In other words, if one set of rules
comes after another set, rules
with the same specificity will be
overridden.
What the heck is it
Established primarily by the
width/height, padding, margin
and border of an object.
Accounts for the on-page space
that a block object occupies over
the course of a page (total width
/ height).
Determines if a float can
happen.
Here’s some dumb math
LEFT MARGIN
+ LEFT BORDER WIDTH
+ LEFT PADDING
+ WIDTH
+ RIGHT PADDING
+ RIGHT BORDER WIDTH
+ RIGHT MARGIN
===============
"Calculated" Width
Width and Height
Raw width / height of an element. How much
space it occupies with no modification.
For instance, a 360px wide image, before any
borders are margins, occupies that much space.
Use “Inspect Element” in Chrome to determine
calculated dimensions with all modifiers.
Padding
Spacing “inside” of an element’s borders.
Padding cannot be negative.
Constrains content to calculated width;
when padding is in a nested element,
parent will not expand.
Borders
Reside outside of padding, inside of margin.
They’re just like a line you can place around an
element. You’ll probably see them a lot. Check
out the cool border on this.
Can be styled in stupid ways (dotted, colored).
Still count to total calculated size.
Marginzzzzzzzzzzzzzzzzzz
Extends from element’s border. Gives form to
spacing outside of an element.
Most useful for positioning elements normally.
Try to use this instead of “top” etc. when
possible; only use that for weirdo positioning.
Set left & right margins to “auto” on block
elements with set width to center the element.
Doesn’t work for top/bottom margins.
Misc. Box Model Stuff
Child elements must fit
within the “width”
property of parent
elements (not calculated)
There’s also the “outline”
property that’s similar to
a border, but does not
count to calculated width
SHORTCUTZZ:
margin/padding:
TOP, RIGHT, BOTTOM, LEFT
element {margin: 200px 0;}
element {
padding: 1px 2px 3px;}
border:
WIDTH, STYLE, COLOR
element {border: 1px solid
#fff;}
Floats
Neatly organize block/inline-block elements.
You can float right, none or left, it’s up to you! But try
to float left as much as possible.
(LTR reading, old Internet Explorer)
Takes into consideration box model for width.
Blocks can float around inline content (text).
Parent element must float to inherit heights!
CLEAR THE FLOATS
Used in unison with floats to “clear” a “line” from a
float.
Cleared elements allow more floats to happen on
next line.
Left, Right or Both
Depending on placement of element, use left or right.
Clearing “BOTH” makes an element appear on its own,
devoid of floats
“Styles” of position:
Static – Default. Try to use as much as possible. Based on
DOM flow.
Relative – Follows DOM. Relative to STATIC position.
Absolute – Relative to first non-static parent. Useful for
form label placement within input fields.
Fixed – ALWAYS stays in place. Useful for “sticky” nav
bars, etc. You don’t wanna use this much.
Gangnam Style - just kiddin
“Positions” for position:
Top, right, bottom, left are all
CSS properties. Set px or %.
Allow you to adjust placement of
an object while utilizing the value
set for the “position” property.
Positioned elements still can use
margins! Use with caution.
Allows for the overlap of elements when using positioning.
Z probably refers to like, X, Y, and Z coordinates; depth.
Just a numerical value with no unit.
Keep track of z-indexed elements.
Z-INDEX
You should be writing good, specific CSS.
However, sometimes you really need to override something.
Use the “!important;” declaration RARELY, since, like, if everything’s
important, nothing’s important. B-)
When to Use “!important”
What’s Responsive????
Similar user experience for multiple devices.
Usually constrained to WIDTH of view.
Use percentages instead of fixed units.
Look at 800theface.com! CSS rules for “break”
points within viewable zones.
When doing custom work for a client’s site (implementing forms, a
404 page or whatever) take into consideration if the site’s
responsive. Work with the AM & Graphics to mockup alternate
approaches to maintain responsive stuff.
Is the Site Responsive?
By!!!!!!!!!!!!!!!!!!!!!!!!!!
Later!!!!!!!

More Related Content

What's hot

Castro Chapter 7
Castro Chapter 7Castro Chapter 7
Castro Chapter 7
Jeff Byrnes
 
Basics Of Css And Some Common Mistakes
Basics Of Css And Some Common MistakesBasics Of Css And Some Common Mistakes
Basics Of Css And Some Common Mistakes
sanjay2211
 

What's hot (19)

CSS
CSSCSS
CSS
 
CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)
 
CSS Positioning and Features of CSS3
CSS Positioning and Features of CSS3CSS Positioning and Features of CSS3
CSS Positioning and Features of CSS3
 
Castro Chapter 7
Castro Chapter 7Castro Chapter 7
Castro Chapter 7
 
CSS_Day_Two (W3schools)
CSS_Day_Two (W3schools)CSS_Day_Two (W3schools)
CSS_Day_Two (W3schools)
 
CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)
 
Css2layout
Css2layoutCss2layout
Css2layout
 
Css position
Css positionCss position
Css position
 
CSS 101
CSS 101CSS 101
CSS 101
 
Ppt ch06
Ppt ch06Ppt ch06
Ppt ch06
 
Basics Of Css And Some Common Mistakes
Basics Of Css And Some Common MistakesBasics Of Css And Some Common Mistakes
Basics Of Css And Some Common Mistakes
 
Css ppt
Css pptCss ppt
Css ppt
 
Cascading style sheet
Cascading style sheetCascading style sheet
Cascading style sheet
 
CSS Positioning
CSS PositioningCSS Positioning
CSS Positioning
 
Responsive web design with html5 and css3
Responsive web design with html5 and css3Responsive web design with html5 and css3
Responsive web design with html5 and css3
 
Intro to CSS
Intro to CSSIntro to CSS
Intro to CSS
 
Margin
MarginMargin
Margin
 
CSS Basic Introduction, Rules, And Tips
CSS Basic Introduction, Rules, And TipsCSS Basic Introduction, Rules, And Tips
CSS Basic Introduction, Rules, And Tips
 
Css3
Css3Css3
Css3
 

Viewers also liked

Impactul economic al saa s asupra unui imm ciobanu emanuela - ap1
Impactul economic al saa s asupra unui imm   ciobanu emanuela - ap1Impactul economic al saa s asupra unui imm   ciobanu emanuela - ap1
Impactul economic al saa s asupra unui imm ciobanu emanuela - ap1
silviu_cojocaru
 
Impactul linux asupra unui imm felicia izabela sterpu ap1
Impactul linux asupra unui imm    felicia izabela sterpu ap1Impactul linux asupra unui imm    felicia izabela sterpu ap1
Impactul linux asupra unui imm felicia izabela sterpu ap1
silviu_cojocaru
 
Risc si incertitudine pe piata cosmeticelor romanesti romascu diana, marketin...
Risc si incertitudine pe piata cosmeticelor romanesti romascu diana, marketin...Risc si incertitudine pe piata cosmeticelor romanesti romascu diana, marketin...
Risc si incertitudine pe piata cosmeticelor romanesti romascu diana, marketin...
silviu_cojocaru
 

Viewers also liked (14)

Kesehatan mental
Kesehatan mentalKesehatan mental
Kesehatan mental
 
Recreo
RecreoRecreo
Recreo
 
Impactul economic al saa s asupra unui imm ciobanu emanuela - ap1
Impactul economic al saa s asupra unui imm   ciobanu emanuela - ap1Impactul economic al saa s asupra unui imm   ciobanu emanuela - ap1
Impactul economic al saa s asupra unui imm ciobanu emanuela - ap1
 
Recreo
RecreoRecreo
Recreo
 
Entrepreneurship - The Introduction
Entrepreneurship - The IntroductionEntrepreneurship - The Introduction
Entrepreneurship - The Introduction
 
BreakFusion 2014 / break'n battles for kids
BreakFusion 2014 / break'n battles for kidsBreakFusion 2014 / break'n battles for kids
BreakFusion 2014 / break'n battles for kids
 
Curriculum 2015 alonzo
Curriculum 2015 alonzoCurriculum 2015 alonzo
Curriculum 2015 alonzo
 
Impactul linux asupra unui imm felicia izabela sterpu ap1
Impactul linux asupra unui imm    felicia izabela sterpu ap1Impactul linux asupra unui imm    felicia izabela sterpu ap1
Impactul linux asupra unui imm felicia izabela sterpu ap1
 
Recreo
RecreoRecreo
Recreo
 
PPP in Municipal Solid Waste Management
PPP in Municipal Solid Waste ManagementPPP in Municipal Solid Waste Management
PPP in Municipal Solid Waste Management
 
Ppt topologies
Ppt topologiesPpt topologies
Ppt topologies
 
Risc si incertitudine pe piata cosmeticelor romanesti romascu diana, marketin...
Risc si incertitudine pe piata cosmeticelor romanesti romascu diana, marketin...Risc si incertitudine pe piata cosmeticelor romanesti romascu diana, marketin...
Risc si incertitudine pe piata cosmeticelor romanesti romascu diana, marketin...
 
A Case-study of Municipal Solid Waste Management at Pattukkottai Municipality
A Case-study of Municipal Solid Waste Management at Pattukkottai MunicipalityA Case-study of Municipal Solid Waste Management at Pattukkottai Municipality
A Case-study of Municipal Solid Waste Management at Pattukkottai Municipality
 
Dart como alternativa a TypeScript (Codemotion 2016)
Dart como alternativa a TypeScript (Codemotion 2016)Dart como alternativa a TypeScript (Codemotion 2016)
Dart como alternativa a TypeScript (Codemotion 2016)
 

Similar to Css training

Css Positioning Elements
Css Positioning ElementsCss Positioning Elements
Css Positioning Elements
sanjay2211
 
Lesson 3 - HTML & CSS Part 2
Lesson 3 - HTML & CSS Part 2Lesson 3 - HTML & CSS Part 2
Lesson 3 - HTML & CSS Part 2
hstryk
 
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
ZahouAmel1
 

Similar to Css training (20)

How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
 
Lecture2 CSS 3
Lecture2   CSS 3Lecture2   CSS 3
Lecture2 CSS 3
 
CSS Part II
CSS Part IICSS Part II
CSS Part II
 
Web Layout
Web LayoutWeb Layout
Web Layout
 
Designing for the web - 101
Designing for the web - 101Designing for the web - 101
Designing for the web - 101
 
Css Positioning Elements
Css Positioning ElementsCss Positioning Elements
Css Positioning Elements
 
Css advanced – session 4
Css advanced – session 4Css advanced – session 4
Css advanced – session 4
 
Web Development 4 (HTML & CSS)
Web Development 4 (HTML & CSS)Web Development 4 (HTML & CSS)
Web Development 4 (HTML & CSS)
 
Web Development 4
Web Development 4Web Development 4
Web Development 4
 
Lesson 3 - HTML & CSS Part 2
Lesson 3 - HTML & CSS Part 2Lesson 3 - HTML & CSS Part 2
Lesson 3 - HTML & CSS Part 2
 
Web Design & Development - Session 3
Web Design & Development - Session 3Web Design & Development - Session 3
Web Design & Development - Session 3
 
Fundamentals of Browser Rendering Css Overview PT 1
Fundamentals of Browser Rendering Css Overview PT 1Fundamentals of Browser Rendering Css Overview PT 1
Fundamentals of Browser Rendering Css Overview PT 1
 
Css from scratch
Css from scratchCss from scratch
Css from scratch
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
 
CSS3 notes
CSS3 notesCSS3 notes
CSS3 notes
 
Advanced CSS.pptx
Advanced CSS.pptxAdvanced CSS.pptx
Advanced CSS.pptx
 
CSS Introduction
CSS Introduction CSS Introduction
CSS Introduction
 
Journey To The Front End World - Part2 - The Cosmetic
Journey To The Front End World - Part2 - The  CosmeticJourney To The Front End World - Part2 - The  Cosmetic
Journey To The Front End World - Part2 - The Cosmetic
 
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
 
Css layouts-continued
Css layouts-continuedCss layouts-continued
Css layouts-continued
 

Css training

  • 1.
  • 2. CSS Overview You know what CSS is: CASCADING STYLE SHEETS. Styling of HTML elements VIA standard rules.
  • 3. Important Topics 1. CSS Syntax / Selectors 2. Including CSS Rules 3. CSS Box Model 4. Floating/Clearing Effectively 5. Positioning 6. Use of “!important” declaration 7. Responsive Considerations
  • 4.
  • 5. Elements, IDs, Classes ID (#foo {prop: set;}) One instance per page (usually). Class (.foo {prop: set;}) Multiple instances per page (often). HTML Element (foo {prop: set;}) Vague! But powerful!
  • 6. Specificity in Selectors Show “lineage” of element (#wrapper #content .cool) Build with effective use of IDs and classes site-wide. Pseudo-selectors: don’t rely on them too much.
  • 7.
  • 8. Ways to Include Rules External Stylesheet (Preferred!) <style> Tag (Helpful! But not portable!) Inline style=“” attribute (Powerful! But messy!)
  • 9. <link> to External Styles Remember position in DOM; later rules will overwrite earlier rules Allows you to keep styles isolated (forms, etc.) and allows portability of styles Makes site-wide styling edits easy! Easy to reference in Chrome Developer Tools
  • 10. <style> Tags Useful for single-page styles Hacky solution for weirdo CMSes (hiding elements that you need to hide, etc.) Not portable, but lets you target multiple elements on the same page VIA IDs, classes, and HTML elements. Happy friday
  • 11. Inline style=“” Attributes Browser gives style=“” attributes most priority. Ve r y p o w e r f u l ! ! Must be manually replicated; not portable! Makes HTML messy Useful for JavaScript stuff
  • 12. More on Specificity… Depending on ordering in DOM and degree of specificity of rule declarations, the more specific rule will override another. In other words, if one set of rules comes after another set, rules with the same specificity will be overridden.
  • 13.
  • 14. What the heck is it Established primarily by the width/height, padding, margin and border of an object. Accounts for the on-page space that a block object occupies over the course of a page (total width / height). Determines if a float can happen.
  • 15. Here’s some dumb math LEFT MARGIN + LEFT BORDER WIDTH + LEFT PADDING + WIDTH + RIGHT PADDING + RIGHT BORDER WIDTH + RIGHT MARGIN =============== "Calculated" Width
  • 16. Width and Height Raw width / height of an element. How much space it occupies with no modification. For instance, a 360px wide image, before any borders are margins, occupies that much space. Use “Inspect Element” in Chrome to determine calculated dimensions with all modifiers.
  • 17. Padding Spacing “inside” of an element’s borders. Padding cannot be negative. Constrains content to calculated width; when padding is in a nested element, parent will not expand.
  • 18. Borders Reside outside of padding, inside of margin. They’re just like a line you can place around an element. You’ll probably see them a lot. Check out the cool border on this. Can be styled in stupid ways (dotted, colored). Still count to total calculated size.
  • 19. Marginzzzzzzzzzzzzzzzzzz Extends from element’s border. Gives form to spacing outside of an element. Most useful for positioning elements normally. Try to use this instead of “top” etc. when possible; only use that for weirdo positioning. Set left & right margins to “auto” on block elements with set width to center the element. Doesn’t work for top/bottom margins.
  • 20. Misc. Box Model Stuff Child elements must fit within the “width” property of parent elements (not calculated) There’s also the “outline” property that’s similar to a border, but does not count to calculated width SHORTCUTZZ: margin/padding: TOP, RIGHT, BOTTOM, LEFT element {margin: 200px 0;} element { padding: 1px 2px 3px;} border: WIDTH, STYLE, COLOR element {border: 1px solid #fff;}
  • 21.
  • 22. Floats Neatly organize block/inline-block elements. You can float right, none or left, it’s up to you! But try to float left as much as possible. (LTR reading, old Internet Explorer) Takes into consideration box model for width. Blocks can float around inline content (text). Parent element must float to inherit heights!
  • 23. CLEAR THE FLOATS Used in unison with floats to “clear” a “line” from a float. Cleared elements allow more floats to happen on next line. Left, Right or Both Depending on placement of element, use left or right. Clearing “BOTH” makes an element appear on its own, devoid of floats
  • 24.
  • 25. “Styles” of position: Static – Default. Try to use as much as possible. Based on DOM flow. Relative – Follows DOM. Relative to STATIC position. Absolute – Relative to first non-static parent. Useful for form label placement within input fields. Fixed – ALWAYS stays in place. Useful for “sticky” nav bars, etc. You don’t wanna use this much. Gangnam Style - just kiddin
  • 26. “Positions” for position: Top, right, bottom, left are all CSS properties. Set px or %. Allow you to adjust placement of an object while utilizing the value set for the “position” property. Positioned elements still can use margins! Use with caution.
  • 27. Allows for the overlap of elements when using positioning. Z probably refers to like, X, Y, and Z coordinates; depth. Just a numerical value with no unit. Keep track of z-indexed elements. Z-INDEX
  • 28.
  • 29. You should be writing good, specific CSS. However, sometimes you really need to override something. Use the “!important;” declaration RARELY, since, like, if everything’s important, nothing’s important. B-) When to Use “!important”
  • 30.
  • 31. What’s Responsive???? Similar user experience for multiple devices. Usually constrained to WIDTH of view. Use percentages instead of fixed units. Look at 800theface.com! CSS rules for “break” points within viewable zones.
  • 32. When doing custom work for a client’s site (implementing forms, a 404 page or whatever) take into consideration if the site’s responsive. Work with the AM & Graphics to mockup alternate approaches to maintain responsive stuff. Is the Site Responsive?