SlideShare a Scribd company logo
1 of 38
Julia Vishnevsky
CSS
• Cascading Style Sheets
• CSS defines how HTML
elements are to be displayed
• The style sheet file must be
saved with a .css extension
WAYS TO INSERT CSS
• External style sheet
• Internal style sheet
• Inline style
STYLE PRECEDENCE IN
CSS
• Browser defaults
• External style sheet
• Internal style sheet
• Inline style
STATEMENT STRUCTURE
• Selector
• Curly braces
• Properties divided by a colon
SELECTORS
HTML TAG
• body {}
• span {}
• div {}
• p {}
ID / CLASS
• Case sensitive
• #my-id {}
• #txtBox {} != #TxtBox {}
• span#some-id {}
• .myClass {}
• div.class {}
DESCENDANT
• The descendant selector matches all
elements that are descendants of a specified
element.
• .parent .who-is-my-father {}
• div span#i-am-inside {}
CHILD SELECTOR
• The child selector selects all elements that
are the immediate children of a specified
element
• #papa > .baby {}
ADJACENT SIBLING
SELECTOR
• The adjacent sibling selector selects all
elements that are the adjacent siblings of a
specified element
• Sibling elements must have the same parent
element, and "adjacent" means "immediately
following”
• #me + .my brother {}
GENERAL SIBLING
SELECTOR
• The general sibling selector selects all
elements that are siblings of a specified
element
• div ~ brothers
PSEUDO SELECTORS
• Used to define a special state of an element
• selector:hover {}
• selector:first-child {}
• selector:nth-child(n) {}
GROUPING
• h1, h2, h3 {}
• footer, header {}
• #green-element, #blue-element {}
COMMENTS
• /* Hi there, I am a comment */
• Please avoid these, css is self explanatory
BROWSER SUPPORT
• Beware with CSS3
• http://www.w3schools.com/cssref/css3_brow
sersupport.asp
JUST SAYING….
PROPERTIES
BOX MODEL
• All HTML elements can be considered as boxes
• The CSS box model is essentially a box that wraps around HTML
elements
• The box model allows us to add a border around elements, and to
define space between elements
MARGINS, PADDING,
BORDER
• p {padding : 20px}
• span {border : 2px solid silver}
• div {margin : 5px 10px 7px 9px}
• p {margin : 10px 5px}
• {top, right, bottom, left} / {top-bottom, right-
left}
POSITION
• static - HTML elements are positioned static by
default
• relative - positioned relative to its normal position
• fixed - is positioned relative to the viewport, which
means it always stays in the same place even if the
page is scrolled
• absolute - is positioned relative to the nearest
positioned ancestor
USEFUL PROPERTIES
• color : red / #FF0000 / rgb(255,0,0)
• font-size: 16px (browser default)
• width: 160px / 90%
• height: 20px
DISPLAY
• The display property specifies the type of box
used for an HTML element
• inline (default) - depends on content size
• inline-block - depends on specified width
• block - depends on ancestor (parent) size
THE INVISIBILITY CLOAK
• display : none
• No space allocated for it.
• You can still interact with it through the dom
• visibility : hidden
• The tag is not visible, but space is allocated on
the page.
BEST PRACTICES
• Use useful naming conventions
• You shouldn’t have to rename the element in your
HTML and rename the id in your style sheet just to
change its position
• Big no no: #red-label
• Another BIG no no: #home-page-footer
• Avoid !important
CSS IN THE <HEAD>
• When you have the CSS declared before <body> starts, your styles has
actually loaded already
• This way you don't render ugly html - html elements are rendered with their
styling.
• This way very quickly users see something appear on their screen (e.g.
background color).
• This way you avoid double rendering - If you leave the the styles somewhere
in the body, the browser has to re-render the page (new and old styling) when
the styles declared are parsed.
• This way you avoid triple rendering - in cases where you have overriding css
statements
RESET.CSS VS.
NORMALIZE.CSS
• Different browsers come with different defaults
• Reset.css aims to remove all built-in browser styling.
• Standard elements like H1-6, p, span, div… end up
looking exactly alike, having no decoration at all.
You're then supposed to add all decoration yourself
• Normalize.css preserves useful defaults rather than
"unstyling" everything
BOOTSTRAP
• Bootstrap is the most popular HTML, CSS,
and JS framework for developing responsive,
mobile first projects on the web
• http://getbootstrap.com
SOME EXTRAS
• Css 3
• Responsive design
• Sprites
• Sass (Syntactically Awesome Style Sheets)
and other css extensions
Css intro

More Related Content

What's hot (20)

Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
 
Css
CssCss
Css
 
Cascading style sheets - CSS
Cascading style sheets - CSSCascading style sheets - CSS
Cascading style sheets - CSS
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Intro to CSS
Intro to CSSIntro to CSS
Intro to CSS
 
Cascading Style Sheets(CSS)
Cascading Style Sheets(CSS)Cascading Style Sheets(CSS)
Cascading Style Sheets(CSS)
 
Web 102 INtro to CSS
Web 102  INtro to CSSWeb 102  INtro to CSS
Web 102 INtro to CSS
 
Css box-model
Css box-modelCss box-model
Css box-model
 
css v1 guru
css v1 gurucss v1 guru
css v1 guru
 
Html
HtmlHtml
Html
 
Css.html
Css.htmlCss.html
Css.html
 
Creative Web 02 - HTML & CSS Basics
Creative Web 02 - HTML & CSS BasicsCreative Web 02 - HTML & CSS Basics
Creative Web 02 - HTML & CSS Basics
 
Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02Cascading Style Sheets - Part 02
Cascading Style Sheets - Part 02
 
Cascading Style Sheets - CSS
Cascading Style Sheets - CSSCascading Style Sheets - CSS
Cascading Style Sheets - CSS
 
CSS
CSSCSS
CSS
 
Introducing Cascading Style Sheets
Introducing Cascading Style SheetsIntroducing Cascading Style Sheets
Introducing Cascading Style Sheets
 
Sass
SassSass
Sass
 
Artdm171 Week5 Css
Artdm171 Week5 CssArtdm171 Week5 Css
Artdm171 Week5 Css
 
CSS, CSS Selectors, CSS Box Model
CSS, CSS Selectors, CSS Box ModelCSS, CSS Selectors, CSS Box Model
CSS, CSS Selectors, CSS Box Model
 
Course outline Website Design & Development
Course outline   Website Design & DevelopmentCourse outline   Website Design & Development
Course outline Website Design & Development
 

Similar to Css intro

BITM3730Week4.pptx
BITM3730Week4.pptxBITM3730Week4.pptx
BITM3730Week4.pptxMattMarino13
 
Unit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptxUnit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptxTanu524249
 
Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01Likitha47
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheetssmithaps4
 
WEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptxWEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptxkarthiksmart21
 
Web design-workflow
Web design-workflowWeb design-workflow
Web design-workflowPeter Kaizer
 
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)Webtech Learning
 
Intro to html, css & sass
Intro to html, css & sassIntro to html, css & sass
Intro to html, css & sassSean Wolfe
 
Getting Started With CSS
Getting Started With CSSGetting Started With CSS
Getting Started With CSSTrisha Crowley
 
basic programming language AND HTML CSS JAVApdf
basic programming language AND HTML CSS JAVApdfbasic programming language AND HTML CSS JAVApdf
basic programming language AND HTML CSS JAVApdfelayelily
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheetssmitha273566
 
BITM3730 9-20.pptx
BITM3730 9-20.pptxBITM3730 9-20.pptx
BITM3730 9-20.pptxMattMarino13
 
BITM3730 9-19.pptx
BITM3730 9-19.pptxBITM3730 9-19.pptx
BITM3730 9-19.pptxMattMarino13
 
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 CosmeticIrfan Maulana
 
Cascading style sheet an introduction
Cascading style sheet   an introductionCascading style sheet   an introduction
Cascading style sheet an introductionHimanshu Pathak
 
Cascading Styling Sheets(CSS) simple design language intended to transform th...
Cascading Styling Sheets(CSS) simple design language intended to transform th...Cascading Styling Sheets(CSS) simple design language intended to transform th...
Cascading Styling Sheets(CSS) simple design language intended to transform th...JebaRaj26
 
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892Deepak Sharma
 

Similar to Css intro (20)

Web Development - Lecture 5
Web Development - Lecture 5Web Development - Lecture 5
Web Development - Lecture 5
 
BITM3730Week4.pptx
BITM3730Week4.pptxBITM3730Week4.pptx
BITM3730Week4.pptx
 
Css
CssCss
Css
 
Unit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptxUnit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptx
 
Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
 
WEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptxWEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptx
 
Web design-workflow
Web design-workflowWeb design-workflow
Web design-workflow
 
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)
 
Intro to html, css & sass
Intro to html, css & sassIntro to html, css & sass
Intro to html, css & sass
 
Getting Started With CSS
Getting Started With CSSGetting Started With CSS
Getting Started With CSS
 
basic programming language AND HTML CSS JAVApdf
basic programming language AND HTML CSS JAVApdfbasic programming language AND HTML CSS JAVApdf
basic programming language AND HTML CSS JAVApdf
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
 
BITM3730 9-20.pptx
BITM3730 9-20.pptxBITM3730 9-20.pptx
BITM3730 9-20.pptx
 
Php workshop L01 CSS
Php workshop L01 CSSPhp workshop L01 CSS
Php workshop L01 CSS
 
BITM3730 9-19.pptx
BITM3730 9-19.pptxBITM3730 9-19.pptx
BITM3730 9-19.pptx
 
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
 
Cascading style sheet an introduction
Cascading style sheet   an introductionCascading style sheet   an introduction
Cascading style sheet an introduction
 
Cascading Styling Sheets(CSS) simple design language intended to transform th...
Cascading Styling Sheets(CSS) simple design language intended to transform th...Cascading Styling Sheets(CSS) simple design language intended to transform th...
Cascading Styling Sheets(CSS) simple design language intended to transform th...
 
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
 

Recently uploaded

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Css intro

  • 2. CSS • Cascading Style Sheets • CSS defines how HTML elements are to be displayed • The style sheet file must be saved with a .css extension
  • 3. WAYS TO INSERT CSS • External style sheet • Internal style sheet • Inline style
  • 4. STYLE PRECEDENCE IN CSS • Browser defaults • External style sheet • Internal style sheet • Inline style
  • 5.
  • 6. STATEMENT STRUCTURE • Selector • Curly braces • Properties divided by a colon
  • 8. HTML TAG • body {} • span {} • div {} • p {}
  • 9. ID / CLASS • Case sensitive • #my-id {} • #txtBox {} != #TxtBox {} • span#some-id {} • .myClass {} • div.class {}
  • 10. DESCENDANT • The descendant selector matches all elements that are descendants of a specified element. • .parent .who-is-my-father {} • div span#i-am-inside {}
  • 11.
  • 12. CHILD SELECTOR • The child selector selects all elements that are the immediate children of a specified element • #papa > .baby {}
  • 13. ADJACENT SIBLING SELECTOR • The adjacent sibling selector selects all elements that are the adjacent siblings of a specified element • Sibling elements must have the same parent element, and "adjacent" means "immediately following” • #me + .my brother {}
  • 14. GENERAL SIBLING SELECTOR • The general sibling selector selects all elements that are siblings of a specified element • div ~ brothers
  • 15.
  • 16. PSEUDO SELECTORS • Used to define a special state of an element • selector:hover {} • selector:first-child {} • selector:nth-child(n) {}
  • 17. GROUPING • h1, h2, h3 {} • footer, header {} • #green-element, #blue-element {}
  • 18. COMMENTS • /* Hi there, I am a comment */ • Please avoid these, css is self explanatory
  • 19.
  • 20. BROWSER SUPPORT • Beware with CSS3 • http://www.w3schools.com/cssref/css3_brow sersupport.asp
  • 23. BOX MODEL • All HTML elements can be considered as boxes • The CSS box model is essentially a box that wraps around HTML elements • The box model allows us to add a border around elements, and to define space between elements
  • 24. MARGINS, PADDING, BORDER • p {padding : 20px} • span {border : 2px solid silver} • div {margin : 5px 10px 7px 9px} • p {margin : 10px 5px} • {top, right, bottom, left} / {top-bottom, right- left}
  • 25.
  • 26. POSITION • static - HTML elements are positioned static by default • relative - positioned relative to its normal position • fixed - is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled • absolute - is positioned relative to the nearest positioned ancestor
  • 27. USEFUL PROPERTIES • color : red / #FF0000 / rgb(255,0,0) • font-size: 16px (browser default) • width: 160px / 90% • height: 20px
  • 28. DISPLAY • The display property specifies the type of box used for an HTML element • inline (default) - depends on content size • inline-block - depends on specified width • block - depends on ancestor (parent) size
  • 29.
  • 30. THE INVISIBILITY CLOAK • display : none • No space allocated for it. • You can still interact with it through the dom • visibility : hidden • The tag is not visible, but space is allocated on the page.
  • 31.
  • 32. BEST PRACTICES • Use useful naming conventions • You shouldn’t have to rename the element in your HTML and rename the id in your style sheet just to change its position • Big no no: #red-label • Another BIG no no: #home-page-footer • Avoid !important
  • 33.
  • 34. CSS IN THE <HEAD> • When you have the CSS declared before <body> starts, your styles has actually loaded already • This way you don't render ugly html - html elements are rendered with their styling. • This way very quickly users see something appear on their screen (e.g. background color). • This way you avoid double rendering - If you leave the the styles somewhere in the body, the browser has to re-render the page (new and old styling) when the styles declared are parsed. • This way you avoid triple rendering - in cases where you have overriding css statements
  • 35. RESET.CSS VS. NORMALIZE.CSS • Different browsers come with different defaults • Reset.css aims to remove all built-in browser styling. • Standard elements like H1-6, p, span, div… end up looking exactly alike, having no decoration at all. You're then supposed to add all decoration yourself • Normalize.css preserves useful defaults rather than "unstyling" everything
  • 36. BOOTSTRAP • Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile first projects on the web • http://getbootstrap.com
  • 37. SOME EXTRAS • Css 3 • Responsive design • Sprites • Sass (Syntactically Awesome Style Sheets) and other css extensions