SlideShare uma empresa Scribd logo
1 de 28
Baixar para ler offline
Cascading Style
Sheets
Taking control of you web pages
Part Deux
What we will learn today

 Pseudo classes and elements
 Block elements vs. Inline elements
 Specificity, Inheritance and the
 Cascade
 Web Developers Tool Bar
 The Box Model
 Positioning Elements
Pseudo Classes

 :link --- Targets a link
 :visited --- Targets a link that has
 been visited by the user
 :hover --- Targets a link that is being
 pointed at by the user
 :active --- Targets a link that is
 currently being clicked
Pseudo Classes

 :focus --- Selects an element, such as a text
 field form, that is the current focus
Pseudo Elements

 :first-child --- Selects the first-child
 element
 :first-letter --- selects first letter
 inside the indicated element
 :first-line --- selects the first line
 inside the indicated element
Block vs. Inline

Inline elements:
Do not create a line-break before or
after their position in the document.
Block level elements:
Create a line-break before and after
their position in the document.
Style Precedence


 Inheritance
 Cascade
 Specificity
Inheritance

<body font-family: verdana, helvetica,
sans-serif; color: blue; font-size 100%;}
The Cascade

 The browser must decide which of
 the many possible sources for a
 particular property for a particular tag
 is the one to use.
Sources of styles

 Browser style sheet
 User style sheet
 Author styles
Simplified Cascade Rules

Rule 1:
The more specific a selector is, the
more likely that it will take precedence
over a less specific selector
Simplified Cascade Rules

Rule 2:
Selectors with ID’s win out over
selectors with classes, which win out
over selectors that are just tags.
Simplified Cascade Rules

Rule 3:
If the same property for the same tag is
defined in more than one location, inline
styles win out over embedded styles,
which win over style sheet styles.
Simplified Cascade Rules

Rule 4:
Defined styles win over inherited styles
regardless of specificity.
Web Developers tool bar

 Standards mode vs. quirks mode
 Outline block level elements
 Display element information
 Validation
 Window resize
Box model

Four things make a box
  Content
  Padding
  Border
  Margin
Box model
Margin and Padding

p {padding-left: 20px;}

p { padding: 20px;}
p { padding: 20px 10px;}
p { padding: 20px 10px 5px 15px;}
p { padding: 20px 10px 5px}
Width of a box

Width of a box is equal to
the width of the content +
the width of the padding +
the width of the border
Vertical Margins Collapse

 Two or more adjoining vertical
 margins of block boxes in the normal
 flow collapse.
 Vertical margins between a floated
 box and any other box do not
 collapse.
 Margins of absolutely and relatively
 positioned boxes do not collapse.
Positioning

Position property
  determines the reference point for the
  positioning of each element box

div {position: relative;
top: 20px;
left: 30px;}
Positioning

Static Positioning
  Each element is laid out one after
  another separated only by margins,
  padding, etc.
  Default setting for block level
  elements
Positioning

Relative Positioning
  Elements is positioned relative to
  where it would be in the static layout
  The space it originally occupied is
  retained
Positioning

Absolute Positioning
  Element is taken out of the flow of the
  document
  Position relative to the first ancestor
  element that is also absolutely
  positioned.
Positioning

Fixed Positioning
   Element is taken out of the flow of the
   document
   Position relative to the view port of
   your screen, and stays in place when
   you scroll
   IDWIMIE
Floating and Clearing

Float
   Moves element out of the normal flow
   of the document
   Elements that follow will sit next to
   the floated element if there is room
Floating and Clearing

Clear
  stops elements from moving up next
  to the floated element

Mais conteúdo relacionado

Semelhante a Introduction to CSS: Part Deux

Semelhante a Introduction to CSS: Part Deux (20)

Designing for the web - 101
Designing for the web - 101Designing for the web - 101
Designing for the web - 101
 
CSS_Dibbo
CSS_DibboCSS_Dibbo
CSS_Dibbo
 
Cssxcountry slides
Cssxcountry slidesCssxcountry slides
Cssxcountry slides
 
Cssxcountry slides
Cssxcountry slidesCssxcountry slides
Cssxcountry slides
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
 
Lecture-8.pptx
Lecture-8.pptxLecture-8.pptx
Lecture-8.pptx
 
CSS
CSSCSS
CSS
 
Css lecture notes
Css lecture notesCss lecture notes
Css lecture notes
 
Lesson 3 - HTML & CSS Part 2
Lesson 3 - HTML & CSS Part 2Lesson 3 - HTML & CSS Part 2
Lesson 3 - HTML & CSS Part 2
 
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 selectors
Css selectorsCss selectors
Css selectors
 
Basic css
Basic cssBasic css
Basic css
 
Week5 ap forms
Week5 ap formsWeek5 ap forms
Week5 ap forms
 
CSS3 Refresher
CSS3 RefresherCSS3 Refresher
CSS3 Refresher
 
CSS- Smacss Design Rule
CSS- Smacss Design RuleCSS- Smacss Design Rule
CSS- Smacss Design Rule
 
Web 2 | CSS - Cascading Style Sheets
Web 2 | CSS - Cascading Style SheetsWeb 2 | CSS - Cascading Style Sheets
Web 2 | CSS - Cascading Style Sheets
 
Css training
Css trainingCss training
Css training
 
Working-With-The-Box-Model-Lesson-5.pptx
Working-With-The-Box-Model-Lesson-5.pptxWorking-With-The-Box-Model-Lesson-5.pptx
Working-With-The-Box-Model-Lesson-5.pptx
 
Web Programming& Scripting Lab
Web Programming& Scripting LabWeb Programming& Scripting Lab
Web Programming& Scripting Lab
 
Web Design & Development - Session 3
Web Design & Development - Session 3Web Design & Development - Session 3
Web Design & Development - Session 3
 

Último

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
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 educationjfdjdjcjdnsjd
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
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 ModelDeepika Singh
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
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 WoodJuan lago vázquez
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
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 FMESafe Software
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
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 WorkerThousandEyes
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
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 challengesrafiqahmad00786416
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 

Último (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
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
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
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
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
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 Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
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
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

Introduction to CSS: Part Deux

  • 1. Cascading Style Sheets Taking control of you web pages Part Deux
  • 2. What we will learn today Pseudo classes and elements Block elements vs. Inline elements Specificity, Inheritance and the Cascade Web Developers Tool Bar The Box Model Positioning Elements
  • 3. Pseudo Classes :link --- Targets a link :visited --- Targets a link that has been visited by the user :hover --- Targets a link that is being pointed at by the user :active --- Targets a link that is currently being clicked
  • 4. Pseudo Classes :focus --- Selects an element, such as a text field form, that is the current focus
  • 5. Pseudo Elements :first-child --- Selects the first-child element :first-letter --- selects first letter inside the indicated element :first-line --- selects the first line inside the indicated element
  • 6.
  • 7. Block vs. Inline Inline elements: Do not create a line-break before or after their position in the document. Block level elements: Create a line-break before and after their position in the document.
  • 8. Style Precedence Inheritance Cascade Specificity
  • 9. Inheritance <body font-family: verdana, helvetica, sans-serif; color: blue; font-size 100%;}
  • 10. The Cascade The browser must decide which of the many possible sources for a particular property for a particular tag is the one to use.
  • 11. Sources of styles Browser style sheet User style sheet Author styles
  • 12. Simplified Cascade Rules Rule 1: The more specific a selector is, the more likely that it will take precedence over a less specific selector
  • 13. Simplified Cascade Rules Rule 2: Selectors with ID’s win out over selectors with classes, which win out over selectors that are just tags.
  • 14. Simplified Cascade Rules Rule 3: If the same property for the same tag is defined in more than one location, inline styles win out over embedded styles, which win over style sheet styles.
  • 15. Simplified Cascade Rules Rule 4: Defined styles win over inherited styles regardless of specificity.
  • 16. Web Developers tool bar Standards mode vs. quirks mode Outline block level elements Display element information Validation Window resize
  • 17. Box model Four things make a box Content Padding Border Margin
  • 19. Margin and Padding p {padding-left: 20px;} p { padding: 20px;} p { padding: 20px 10px;} p { padding: 20px 10px 5px 15px;} p { padding: 20px 10px 5px}
  • 20. Width of a box Width of a box is equal to the width of the content + the width of the padding + the width of the border
  • 21. Vertical Margins Collapse Two or more adjoining vertical margins of block boxes in the normal flow collapse. Vertical margins between a floated box and any other box do not collapse. Margins of absolutely and relatively positioned boxes do not collapse.
  • 22. Positioning Position property determines the reference point for the positioning of each element box div {position: relative; top: 20px; left: 30px;}
  • 23. Positioning Static Positioning Each element is laid out one after another separated only by margins, padding, etc. Default setting for block level elements
  • 24. Positioning Relative Positioning Elements is positioned relative to where it would be in the static layout The space it originally occupied is retained
  • 25. Positioning Absolute Positioning Element is taken out of the flow of the document Position relative to the first ancestor element that is also absolutely positioned.
  • 26. Positioning Fixed Positioning Element is taken out of the flow of the document Position relative to the view port of your screen, and stays in place when you scroll IDWIMIE
  • 27. Floating and Clearing Float Moves element out of the normal flow of the document Elements that follow will sit next to the floated element if there is room
  • 28. Floating and Clearing Clear stops elements from moving up next to the floated element