SlideShare a Scribd company logo
1 of 13
WEBD 162
Week 8: display property, Float and Clear
Rethink the web page
• Think of a web page as consisting of rectangular
elements:
Block-level elements
• May only be used within a body element
• If no width is set, will expand to fill the entire space of its
parent element (container)
• If no height is set, will expand to fit its child elements
• As long as child elements are not floated or positioned
• Can have margins and padding
• Will be placed below previous elements in the markup
• If surrounding elements are not floated or positioned
• Typically has a newline before and after the element
• "Ignores" the vertical-align property
• Parent container height may be undefined
• Various workarounds for this design challenge
Block-level elements (learned so far)
address
article
aside
blockquote
dd
div
dl
figcaption
figure
footer
h1
h2
h3
h4
h5
h6
header
hgroup
hr
main
nav
ol
output
p
pre
section
ul
Inline elements
• "Flows" with text content
• Will not automatically clear previous content to drop to the next line
• Subject to white-space settings in CSS
• Ignores top and bottom margin settings
• Will apply left and right margin settings, and any padding settings
• Ignores width and height properties
• If floated left or right, will automatically become a block-
level element
• Subject to vertical-align property
Inline elements (learned so far)
a
abbr
b
big
br
cite
code
dfn
em
i
kbd
q
s
samp
small
span
strong
sub
time
u
var
wbr
Replaced elements
• Appearance and dimensions defined by external resource
• Neither block nor inline
• Acts more like inline ("flows" with text)
• Has block-like structure
• img
• Height, width attributes
• Obsolete (use CSS): hspace, vspace, border attributes
• Other replaced elements include:
• object
• video
• form elements (textarea and input)
display property
• Controls layout by setting how an element is presented
• block – Display as a block
• table – Display as a web table
• inline – Display inline within a block
• inline-block – Treat as a block placed in-line within
another block
• run-in – Display as a block unless next sibling is also a
block; if so, display in-line (combine the blocks together)
• inherit – Inherits display property of parent element
• list-item – Display as a list item with a bullet marker
• none – Do not display, remove from rendered page
display properties info
• quirksmode
• http://quirksmode.org/css/css2/display.html
• Shows how the different display properties look
• Lists which browsers support the display property
• CSS-Tricks
• https://css-tricks.com/almanac/properties/d/display/
Float
• Primarily used to flow text around images
• Also a way to create multi-column layout
• Float pulls an element out of the normal document flow
• Pushes element as far to the left (or right) as possible
within its containing element
• Floated element must appear directly before, or be nested
at the start of, the non-floated element
• Undimensioned surrounding text will flow around the
floated element
• Dimensioned text will be beside the floated element, if
there is room (columns)
http://www.w3.org/TR/CSS2/visuren.html#floats
Clear
• Used to prevent an element from moving up next to a
floated element
• Keeps the element below the floated element
• To clear a previous float without requiring extra markup
• 4 options:
• left
• right
• both
• none
Float and Clear demo
• Stylin’ with CSS, 2nd Edition, Charles Wyke-Smith
• Chapter 4, p. 114-119
Float and Clear Tutorials
• http://css-tricks.com/all-about-floats/
• http://alistapart.com/article/css-floats-101
• http://www.quirksmode.org/css/clearing.html
• http://stackoverflow.com/questions/12871710/why-clear-
both-css
• http://phrogz.net/css/understandingfloats.html

More Related Content

Similar to Display Property, Float and Clear in Web Design

Code & Design your first website 4/18
Code & Design your first website 4/18Code & Design your first website 4/18
Code & Design your first website 4/18TJ Stalcup
 
Cross Browser Issues - few solutions inspired by smashing magazine
Cross Browser Issues - few solutions inspired by smashing magazineCross Browser Issues - few solutions inspired by smashing magazine
Cross Browser Issues - few solutions inspired by smashing magazinePrabhakaran Mani
 
Code & design your first website (3:16)
Code & design your first website (3:16)Code & design your first website (3:16)
Code & design your first website (3:16)Thinkful
 
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 1Barak Drechsler
 
Introduction to Responsive Web Development
Introduction to Responsive Web DevelopmentIntroduction to Responsive Web Development
Introduction to Responsive Web DevelopmentNikhil Baby
 
What's a web page made of?
What's a web page made of?What's a web page made of?
What's a web page made of?Charlie Allen
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksAmit Tyagi
 
Web Development 4 (HTML & CSS)
Web Development 4 (HTML & CSS)Web Development 4 (HTML & CSS)
Web Development 4 (HTML & CSS)ghayour abbas
 
Sane CSS - A modern approach to CSS
Sane CSS - A modern approach to CSSSane CSS - A modern approach to CSS
Sane CSS - A modern approach to CSSLee Cheneler
 
Introduction to Frontend Development - Session 2 - CSS Fundamentals
Introduction to Frontend Development - Session 2 - CSS FundamentalsIntroduction to Frontend Development - Session 2 - CSS Fundamentals
Introduction to Frontend Development - Session 2 - CSS FundamentalsKalin Chernev
 
1 07-2-css floats-and_positioning
1 07-2-css floats-and_positioning1 07-2-css floats-and_positioning
1 07-2-css floats-and_positioningapnwebdev
 
W3Conf slides - The top web features from caniuse.com you can use today
W3Conf slides - The top web features from caniuse.com you can use todayW3Conf slides - The top web features from caniuse.com you can use today
W3Conf slides - The top web features from caniuse.com you can use todayadeveria
 

Similar to Display Property, Float and Clear in Web Design (20)

Css intro
Css introCss intro
Css intro
 
Code & Design your first website 4/18
Code & Design your first website 4/18Code & Design your first website 4/18
Code & Design your first website 4/18
 
Cross Browser Issues - few solutions inspired by smashing magazine
Cross Browser Issues - few solutions inspired by smashing magazineCross Browser Issues - few solutions inspired by smashing magazine
Cross Browser Issues - few solutions inspired by smashing magazine
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
CSS 201
CSS 201CSS 201
CSS 201
 
Code & design your first website (3:16)
Code & design your first website (3:16)Code & design your first website (3:16)
Code & design your first website (3:16)
 
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
 
Introduction to Responsive Web Development
Introduction to Responsive Web DevelopmentIntroduction to Responsive Web Development
Introduction to Responsive Web Development
 
CSS
CSSCSS
CSS
 
CSS Introduction
CSS Introduction CSS Introduction
CSS Introduction
 
What's a web page made of?
What's a web page made of?What's a web page made of?
What's a web page made of?
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
 
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)
 
CSS
CSSCSS
CSS
 
CSS3 Refresher
CSS3 RefresherCSS3 Refresher
CSS3 Refresher
 
Sane CSS - A modern approach to CSS
Sane CSS - A modern approach to CSSSane CSS - A modern approach to CSS
Sane CSS - A modern approach to CSS
 
Introduction to Frontend Development - Session 2 - CSS Fundamentals
Introduction to Frontend Development - Session 2 - CSS FundamentalsIntroduction to Frontend Development - Session 2 - CSS Fundamentals
Introduction to Frontend Development - Session 2 - CSS Fundamentals
 
1 07-2-css floats-and_positioning
1 07-2-css floats-and_positioning1 07-2-css floats-and_positioning
1 07-2-css floats-and_positioning
 
W3Conf slides - The top web features from caniuse.com you can use today
W3Conf slides - The top web features from caniuse.com you can use todayW3Conf slides - The top web features from caniuse.com you can use today
W3Conf slides - The top web features from caniuse.com you can use today
 

Recently uploaded

भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 

Recently uploaded (20)

भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 

Display Property, Float and Clear in Web Design

  • 1. WEBD 162 Week 8: display property, Float and Clear
  • 2. Rethink the web page • Think of a web page as consisting of rectangular elements:
  • 3. Block-level elements • May only be used within a body element • If no width is set, will expand to fill the entire space of its parent element (container) • If no height is set, will expand to fit its child elements • As long as child elements are not floated or positioned • Can have margins and padding • Will be placed below previous elements in the markup • If surrounding elements are not floated or positioned • Typically has a newline before and after the element • "Ignores" the vertical-align property • Parent container height may be undefined • Various workarounds for this design challenge
  • 4. Block-level elements (learned so far) address article aside blockquote dd div dl figcaption figure footer h1 h2 h3 h4 h5 h6 header hgroup hr main nav ol output p pre section ul
  • 5. Inline elements • "Flows" with text content • Will not automatically clear previous content to drop to the next line • Subject to white-space settings in CSS • Ignores top and bottom margin settings • Will apply left and right margin settings, and any padding settings • Ignores width and height properties • If floated left or right, will automatically become a block- level element • Subject to vertical-align property
  • 6. Inline elements (learned so far) a abbr b big br cite code dfn em i kbd q s samp small span strong sub time u var wbr
  • 7. Replaced elements • Appearance and dimensions defined by external resource • Neither block nor inline • Acts more like inline ("flows" with text) • Has block-like structure • img • Height, width attributes • Obsolete (use CSS): hspace, vspace, border attributes • Other replaced elements include: • object • video • form elements (textarea and input)
  • 8. display property • Controls layout by setting how an element is presented • block – Display as a block • table – Display as a web table • inline – Display inline within a block • inline-block – Treat as a block placed in-line within another block • run-in – Display as a block unless next sibling is also a block; if so, display in-line (combine the blocks together) • inherit – Inherits display property of parent element • list-item – Display as a list item with a bullet marker • none – Do not display, remove from rendered page
  • 9. display properties info • quirksmode • http://quirksmode.org/css/css2/display.html • Shows how the different display properties look • Lists which browsers support the display property • CSS-Tricks • https://css-tricks.com/almanac/properties/d/display/
  • 10. Float • Primarily used to flow text around images • Also a way to create multi-column layout • Float pulls an element out of the normal document flow • Pushes element as far to the left (or right) as possible within its containing element • Floated element must appear directly before, or be nested at the start of, the non-floated element • Undimensioned surrounding text will flow around the floated element • Dimensioned text will be beside the floated element, if there is room (columns) http://www.w3.org/TR/CSS2/visuren.html#floats
  • 11. Clear • Used to prevent an element from moving up next to a floated element • Keeps the element below the floated element • To clear a previous float without requiring extra markup • 4 options: • left • right • both • none
  • 12. Float and Clear demo • Stylin’ with CSS, 2nd Edition, Charles Wyke-Smith • Chapter 4, p. 114-119
  • 13. Float and Clear Tutorials • http://css-tricks.com/all-about-floats/ • http://alistapart.com/article/css-floats-101 • http://www.quirksmode.org/css/clearing.html • http://stackoverflow.com/questions/12871710/why-clear- both-css • http://phrogz.net/css/understandingfloats.html

Editor's Notes

  1. http://www.smashingmagazine.com/2009/10/19/the-mystery-of-css-float-property/