SlideShare a Scribd company logo
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.
Fundamentals of Browser Rendering Css Overview PT 1
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 (20)

PDF
Web Design & Development - Session 3
Shahrzad Peyman
 
PPT
gdg_workshop 4 on web development HTML & CSS
SaniyaKhan484230
 
PDF
#2 - CSS Layouts Overview
iloveigloo
 
PPTX
Working-With-The-Box-Model-Lesson-5.pptx
AxestetikrieyHales
 
PPTX
Css training
Leigh Aucoin
 
PDF
Css from scratch
Ahmad Al-ammar
 
PPTX
cascading style sheet powerpoint notes.pptx
kcdiya58
 
PPT
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
PPTX
Designing for the web - 101
Ashraf Hamdy
 
PPTX
MTA css layouts
Dhairya Joshi
 
PDF
Intro to HTML and CSS basics
Eliran Eliassy
 
PPTX
CSS_Dibbo
Sayanton Vhaduri
 
PPTX
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
ZahouAmel1
 
PDF
css.pdf
AbdulRafayawan
 
PDF
But what about old browsers?
Rachel Andrew
 
PPTX
Bootstrap SLIDES for web development course
dreamy678
 
PDF
Intro to CSS
Randy Oest II
 
PDF
Flexbox and Grid Layout: How you will structure layouts tomorrow.
Diego Eis
 
PDF
Html frames
eShikshak
 
Web Design & Development - Session 3
Shahrzad Peyman
 
gdg_workshop 4 on web development HTML & CSS
SaniyaKhan484230
 
#2 - CSS Layouts Overview
iloveigloo
 
Working-With-The-Box-Model-Lesson-5.pptx
AxestetikrieyHales
 
Css training
Leigh Aucoin
 
Css from scratch
Ahmad Al-ammar
 
cascading style sheet powerpoint notes.pptx
kcdiya58
 
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
Designing for the web - 101
Ashraf Hamdy
 
MTA css layouts
Dhairya Joshi
 
Intro to HTML and CSS basics
Eliran Eliassy
 
CSS_Dibbo
Sayanton Vhaduri
 
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
ZahouAmel1
 
But what about old browsers?
Rachel Andrew
 
Bootstrap SLIDES for web development course
dreamy678
 
Intro to CSS
Randy Oest II
 
Flexbox and Grid Layout: How you will structure layouts tomorrow.
Diego Eis
 
Html frames
eShikshak
 

More from Barak Drechsler (7)

PPTX
Stay lazy, use lerna
Barak Drechsler
 
PPTX
Atomic javascript
Barak Drechsler
 
PPTX
Room service (worker) please!
Barak Drechsler
 
PPTX
From MVC to Component Based Architecture
Barak Drechsler
 
PPTX
Js: master prototypes
Barak Drechsler
 
PPTX
Understanding the flex layout
Barak Drechsler
 
PPTX
Javascript: master this
Barak Drechsler
 
Stay lazy, use lerna
Barak Drechsler
 
Atomic javascript
Barak Drechsler
 
Room service (worker) please!
Barak Drechsler
 
From MVC to Component Based Architecture
Barak Drechsler
 
Js: master prototypes
Barak Drechsler
 
Understanding the flex layout
Barak Drechsler
 
Javascript: master this
Barak Drechsler
 
Ad

Recently uploaded (20)

PDF
Beginning-Laravel-Build-Websites-with-Laravel-5.8-by-Sanjib-Sinha-z-lib.org.pdf
TagumLibuganonRiverB
 
PDF
web application development company in bangalore.pdf
https://dkpractice.co.in/seo.html tech
 
PPTX
原版一样(ANU毕业证书)澳洲澳大利亚国立大学毕业证在线购买
Taqyea
 
PDF
Download Google Chrome for Fast and Secure Web Browsing Experience
hgfdsqetuiplmnvcz43
 
PDF
I Want to join occult brotherhood for money ritual#((+2347089754903))
haragonoccult
 
PPT
Almos Entirely Correct Mixing with Apps to Voting
gapati2964
 
PPTX
BitRecover OST to PST Converter Software
antoniogosling01
 
PDF
03 Internal Analysis Strategik Manajemen.pdf
AhmadRifaldhi
 
PPTX
原版一样(ISM毕业证书)德国多特蒙德国际管理学院毕业证多少钱
taqyed
 
PDF
Transmission Control Protocol (TCP) and Starlink
APNIC
 
PDF
ContextForge MCP Gateway - the missing proxy for AI Agents and Tools
Mihai Criveti
 
PDF
Materi tentang From Digital Economy to Fintech.pdf
Abdul Hakim
 
PPTX
Lesson 1.1 Career-Opportunities-in-Ict.pptx
lizelgumadlas1
 
PDF
B M Mostofa Kamal Al-Azad [Document & Localization Expert]
Mostofa Kamal Al-Azad
 
PPTX
The ARUBA Kind of new Proposal Umum .pptx
andiwarneri
 
PDF
The Convergence of Threat Behaviors Across Intrusions
Joe Slowik
 
PPTX
Q1 English3 Week5 [email protected]
JenniferCawaling1
 
PDF
BroadLink Cloud Service introduction.pdf
DevendraDwivdi1
 
PPTX
Class_4_Limbgvchgchgchgchgchgcjhgchgcnked_Lists.pptx
test123n
 
PDF
Clive Dickens RedTech Public Copy - Collaborate or Die
Clive Dickens
 
Beginning-Laravel-Build-Websites-with-Laravel-5.8-by-Sanjib-Sinha-z-lib.org.pdf
TagumLibuganonRiverB
 
web application development company in bangalore.pdf
https://dkpractice.co.in/seo.html tech
 
原版一样(ANU毕业证书)澳洲澳大利亚国立大学毕业证在线购买
Taqyea
 
Download Google Chrome for Fast and Secure Web Browsing Experience
hgfdsqetuiplmnvcz43
 
I Want to join occult brotherhood for money ritual#((+2347089754903))
haragonoccult
 
Almos Entirely Correct Mixing with Apps to Voting
gapati2964
 
BitRecover OST to PST Converter Software
antoniogosling01
 
03 Internal Analysis Strategik Manajemen.pdf
AhmadRifaldhi
 
原版一样(ISM毕业证书)德国多特蒙德国际管理学院毕业证多少钱
taqyed
 
Transmission Control Protocol (TCP) and Starlink
APNIC
 
ContextForge MCP Gateway - the missing proxy for AI Agents and Tools
Mihai Criveti
 
Materi tentang From Digital Economy to Fintech.pdf
Abdul Hakim
 
Lesson 1.1 Career-Opportunities-in-Ict.pptx
lizelgumadlas1
 
B M Mostofa Kamal Al-Azad [Document & Localization Expert]
Mostofa Kamal Al-Azad
 
The ARUBA Kind of new Proposal Umum .pptx
andiwarneri
 
The Convergence of Threat Behaviors Across Intrusions
Joe Slowik
 
BroadLink Cloud Service introduction.pdf
DevendraDwivdi1
 
Class_4_Limbgvchgchgchgchgchgcjhgchgcnked_Lists.pptx
test123n
 
Clive Dickens RedTech Public Copy - Collaborate or Die
Clive Dickens
 
Ad

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.
  • 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

  • #5: https://developers.google.com/web/fundamentals/performance/critical-rendering-path/render-tree-construction
  • #6: https://developers.google.com/web/fundamentals/performance/critical-rendering-path/render-tree-construction
  • #14: https://github.com/vasanthk/css-refresher-notes
  • #15: https://github.com/vasanthk/css-refresher-notes
  • #16: https://github.com/vasanthk/css-refresher-notes
  • #18: https://github.com/vasanthk/css-refresher-notes
  • #19: https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Introduction
  • #20: https://developer.mozilla.org/en-US/docs/Web/CSS/float
  • #22: https://developer.mozilla.org/en-US/docs/Web/CSS/float