SlideShare a Scribd company logo
1 of 22
The fundamentals
of the browser
rendering - part 1
By Barak Drechsler
How css feels like...
How css
should feel...
Web
rendering
flow
1. Process HTML markup and build the DOM
tree.
2. Process CSS markup and build the CSSOM
tree.
3. Combine the DOM and CSSOM into a render
tree.
4. Run layout on the render tree to compute
geometry of each node.
5. Paint the individual nodes to the screen.
The web
building
blocks are
boxes
The CSS box model is the foundation of layout
on the Web — each element is represented as a
rectangular box, with the box's content,
padding, border, and margin built up around
one another like the layers of an onion.
As a browser renders a web page layout, it
works out what styles are applied to the content
of each box, how big the surrounding onion
layers are, and where the boxes sit in relation to
one another.
The Box Model
(content-box)
The Box Model
(border-box)
Play Time - Box Models
https://plnkr.co/edit/XNYbkiuXiS
H49haIhdCv?p=preview
Quick recap for the box
properties
Overflow: defaults to visible, requires the
box to have explicit height, or percentage to
be calculated by parent element height.
Height: isn’t inherited! Any div in the way
can interfere with it children heights
Border, padding, margin, are
straightforward...
Play Time - Height & Overflow
https://plnkr.co/edit/23kJgu8u1A
ssnLlHVt27?p=preview
Boxes types...
Block
Inline
Inline-block
none
(table, flex, grid)
Block
Block level elements do not sit inline, but break past them. If no width is set, will expand naturally
to fill its parent container.
Can have margins and/or padding.
If no height is set, will expand naturally to fit its child elements (assuming they are not floated or
positioned). So, for a block element, it’s not necessary to give it a set width or to give it a width of
100%.
Ignores the vertical-align property.
Inline
Default value for elements. Think of elements like span, b or em
Will ignore top and bottom margin/padding settings, but will apply left and right margin/padding.
Only moves horizontally, not vertically.
Is subject to vertical-align property.
Will ignore width and height properties.
If floated left or right, will automatically become a block-level element, subject to all block
characteristics.
Inline Block
Very similar to inline to its parents in that it will set inline with the natural flow of text.
Very similar to block to its children in that it can have a width and height and its content can
move vertically.
Think of a display:block element that has been rendered (or converted to an image) and then
placed in the document inline
Margin and paddings work properly.
Width and height will be respected.
Play Time - inline, block, inline-
block
https://codepen.io/barakdr/pen/
GNrBRg
Summary
1. We discussed the browser rendering flow DOM + CSSOM => Render Tree => Layout =>
paint.
2. Each element is box.
3. It height is defined by it box-model, either (content-box or border-box).
4. We have a different types of boxes which affect element behaviour (inline, block, inline-
block, flex, none)
The road ahead...
We now have to see, how can we affect how elements are being put together.
The ways to manipulate browser layout:
Floats
Positioning - next session
CSS tables
Flexbox
Grid
Float
The float CSS property specifies that an element should be taken from the normal flow and
placed along the left or right side of its container, where text and inline elements will wrap
around it.
A floating element is one where the computed value of float is not none.
(MDN)
Play Time - floats
https://plnkr.co/edit/Bz4hS2E9e
mkbr3fvts16?p=preview
Float - summary
1. When an element is floated it is taken out of the normal flow of the document. It is shifted
to the left or right until it touches the edge of its containing box or another floated element.
2. Float elements must be given explicit width, otherwise unexpected behavior could occur.
3. Non-positioned, non-floated, block-level elements act as if the floated element is not there.
4. To make parent of floats take it height, we must clear the floats, a trick could be adding
overflow: auto.
5. Bootstrap grid system is float based.
Questions?

More Related Content

Similar to Fundamentals of Browser Rendering Css Overview PT 1

Web Design & Development - Session 3
Web Design & Development - Session 3Web Design & Development - Session 3
Web Design & Development - Session 3Shahrzad Peyman
 
#2 - CSS Layouts Overview
#2 - CSS Layouts Overview#2 - CSS Layouts Overview
#2 - CSS Layouts Overviewiloveigloo
 
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.pptxAxestetikrieyHales
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksAmit Tyagi
 
Designing for the web - 101
Designing for the web - 101Designing for the web - 101
Designing for the web - 101Ashraf Hamdy
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basicsEliran Eliassy
 
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvvZahouAmel1
 
But what about old browsers?
But what about old browsers?But what about old browsers?
But what about old browsers?Rachel Andrew
 
Flexbox and Grid Layout: How you will structure layouts tomorrow.
Flexbox and Grid Layout: How you will structure layouts tomorrow.Flexbox and Grid Layout: How you will structure layouts tomorrow.
Flexbox and Grid Layout: How you will structure layouts tomorrow.Diego Eis
 
Web Development 4 (HTML & CSS)
Web Development 4 (HTML & CSS)Web Development 4 (HTML & CSS)
Web Development 4 (HTML & CSS)ghayour abbas
 

Similar to Fundamentals of Browser Rendering Css Overview PT 1 (20)

Web Design & Development - Session 3
Web Design & Development - Session 3Web Design & Development - Session 3
Web Design & Development - Session 3
 
#2 - CSS Layouts Overview
#2 - CSS Layouts Overview#2 - CSS Layouts Overview
#2 - CSS Layouts Overview
 
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
 
Css training
Css trainingCss training
Css training
 
CSS
CSSCSS
CSS
 
Css from scratch
Css from scratchCss from scratch
Css from scratch
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
 
Designing for the web - 101
Designing for the web - 101Designing for the web - 101
Designing for the web - 101
 
MTA css layouts
MTA css layoutsMTA css layouts
MTA css layouts
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
 
CSS_Dibbo
CSS_DibboCSS_Dibbo
CSS_Dibbo
 
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
 
css.pdf
css.pdfcss.pdf
css.pdf
 
But what about old browsers?
But what about old browsers?But what about old browsers?
But what about old browsers?
 
Intro to CSS
Intro to CSSIntro to CSS
Intro to CSS
 
Flexbox and Grid Layout: How you will structure layouts tomorrow.
Flexbox and Grid Layout: How you will structure layouts tomorrow.Flexbox and Grid Layout: How you will structure layouts tomorrow.
Flexbox and Grid Layout: How you will structure layouts tomorrow.
 
Html frames
Html framesHtml frames
Html frames
 
HTML and CSS part 3
HTML and CSS part 3HTML and CSS part 3
HTML and CSS part 3
 
Web Development 4
Web Development 4Web Development 4
Web Development 4
 
Web Development 4 (HTML & CSS)
Web Development 4 (HTML & CSS)Web Development 4 (HTML & CSS)
Web Development 4 (HTML & CSS)
 

More from Barak Drechsler

Room service (worker) please!
Room service (worker) please!Room service (worker) please!
Room service (worker) please!Barak Drechsler
 
From MVC to Component Based Architecture
From MVC to Component Based ArchitectureFrom MVC to Component Based Architecture
From MVC to Component Based ArchitectureBarak Drechsler
 
Understanding the flex layout
Understanding the flex layoutUnderstanding the flex layout
Understanding the flex layoutBarak Drechsler
 

More from Barak Drechsler (7)

Stay lazy, use lerna
Stay lazy, use lernaStay lazy, use lerna
Stay lazy, use lerna
 
Atomic javascript
Atomic javascriptAtomic javascript
Atomic javascript
 
Room service (worker) please!
Room service (worker) please!Room service (worker) please!
Room service (worker) please!
 
From MVC to Component Based Architecture
From MVC to Component Based ArchitectureFrom MVC to Component Based Architecture
From MVC to Component Based Architecture
 
Js: master prototypes
Js: master prototypesJs: master prototypes
Js: master prototypes
 
Understanding the flex layout
Understanding the flex layoutUnderstanding the flex layout
Understanding the flex layout
 
Javascript: master this
Javascript: master thisJavascript: master this
Javascript: master this
 

Recently uploaded

'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...APNIC
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...Neha Pandey
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersDamian Radcliffe
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024APNIC
 
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.soniya singh
 
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.CarlotaBedoya1
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...singhpriety023
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...Diya Sharma
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Sheetaleventcompany
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)Delhi Call girls
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebJames Anderson
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$kojalkojal131
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445ruhi
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...tanu pandey
 

Recently uploaded (20)

'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
 
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
Russian Call Girls in %(+971524965298  )#  Call Girls in DubaiRussian Call Girls in %(+971524965298  )#  Call Girls in Dubai
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 

Fundamentals of Browser Rendering Css Overview PT 1

  • 1. The fundamentals of the browser rendering - part 1 By Barak Drechsler
  • 2. How css feels like...
  • 4. Web rendering flow 1. Process HTML markup and build the DOM tree. 2. Process CSS markup and build the CSSOM tree. 3. Combine the DOM and CSSOM into a render tree. 4. Run layout on the render tree to compute geometry of each node. 5. Paint the individual nodes to the screen.
  • 5.
  • 6. The web building blocks are boxes The CSS box model is the foundation of layout on the Web — each element is represented as a rectangular box, with the box's content, padding, border, and margin built up around one another like the layers of an onion. As a browser renders a web page layout, it works out what styles are applied to the content of each box, how big the surrounding onion layers are, and where the boxes sit in relation to one another.
  • 9. Play Time - Box Models https://plnkr.co/edit/XNYbkiuXiS H49haIhdCv?p=preview
  • 10. Quick recap for the box properties Overflow: defaults to visible, requires the box to have explicit height, or percentage to be calculated by parent element height. Height: isn’t inherited! Any div in the way can interfere with it children heights Border, padding, margin, are straightforward...
  • 11. Play Time - Height & Overflow https://plnkr.co/edit/23kJgu8u1A ssnLlHVt27?p=preview
  • 13. Block Block level elements do not sit inline, but break past them. If no width is set, will expand naturally to fill its parent container. Can have margins and/or padding. If no height is set, will expand naturally to fit its child elements (assuming they are not floated or positioned). So, for a block element, it’s not necessary to give it a set width or to give it a width of 100%. Ignores the vertical-align property.
  • 14. Inline Default value for elements. Think of elements like span, b or em Will ignore top and bottom margin/padding settings, but will apply left and right margin/padding. Only moves horizontally, not vertically. Is subject to vertical-align property. Will ignore width and height properties. If floated left or right, will automatically become a block-level element, subject to all block characteristics.
  • 15. Inline Block Very similar to inline to its parents in that it will set inline with the natural flow of text. Very similar to block to its children in that it can have a width and height and its content can move vertically. Think of a display:block element that has been rendered (or converted to an image) and then placed in the document inline Margin and paddings work properly. Width and height will be respected.
  • 16. Play Time - inline, block, inline- block https://codepen.io/barakdr/pen/ GNrBRg
  • 17. Summary 1. We discussed the browser rendering flow DOM + CSSOM => Render Tree => Layout => paint. 2. Each element is box. 3. It height is defined by it box-model, either (content-box or border-box). 4. We have a different types of boxes which affect element behaviour (inline, block, inline- block, flex, none)
  • 18. The road ahead... We now have to see, how can we affect how elements are being put together. The ways to manipulate browser layout: Floats Positioning - next session CSS tables Flexbox Grid
  • 19. Float The float CSS property specifies that an element should be taken from the normal flow and placed along the left or right side of its container, where text and inline elements will wrap around it. A floating element is one where the computed value of float is not none. (MDN)
  • 20. Play Time - floats https://plnkr.co/edit/Bz4hS2E9e mkbr3fvts16?p=preview
  • 21. Float - summary 1. When an element is floated it is taken out of the normal flow of the document. It is shifted to the left or right until it touches the edge of its containing box or another floated element. 2. Float elements must be given explicit width, otherwise unexpected behavior could occur. 3. Non-positioned, non-floated, block-level elements act as if the floated element is not there. 4. To make parent of floats take it height, we must clear the floats, a trick could be adding overflow: auto. 5. Bootstrap grid system is float based.

Editor's Notes

  1. https://developers.google.com/web/fundamentals/performance/critical-rendering-path/render-tree-construction
  2. https://developers.google.com/web/fundamentals/performance/critical-rendering-path/render-tree-construction
  3. https://github.com/vasanthk/css-refresher-notes
  4. https://github.com/vasanthk/css-refresher-notes
  5. https://github.com/vasanthk/css-refresher-notes
  6. https://github.com/vasanthk/css-refresher-notes
  7. https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Introduction
  8. https://developer.mozilla.org/en-US/docs/Web/CSS/float
  9. https://developer.mozilla.org/en-US/docs/Web/CSS/float