SlideShare a Scribd company logo
Static layouts with CSS
How to layout webpages using the display, float,
             clear, and properties
CSS layout basics, in 10 slides
CSS layout basics, in 10 slides
display: inline

• Used mostly for text, which “fills up”
  its container

• Inline element types include span, a,
  strong, em, and (confusingly) img

• New elements go on the same line,
  immediately after the previous one
Inline span elements




<span class="first">Lorem ipsum dolor ...</span>
<span class="second">Ut enim ad minim veniam, ...</span>
display: block

• Structural elements that allow you to
  set width/height, margins, padding
  and borders

• Block element types include div, p,
  form, h1, h2, h3, etc.

• New elements stack vertically
Block div elements




<div class="first">Lorem ipsum dolor ...</div>
<div class="second">Ut enim ad minim veniam, ...</div>
CSS Box Model




                        Block only
                                         •   width, height

                                         •   padding

                                         •

                        Inline + block
                                             border

                                         •   margin


Diagram by Rich Hauck
float: left, float: right

• Floating causes block elements to
  stack horizontally

• Elements keep stacking until the
  container width is filled

• Additional elements are added below,
  much like inline content does
Floated divs




<div   class="float">Lorem ipsum dolor sit amet</div>
<div   class="float">consectetur adipisicing elit,</div>
<div   class="float">sed do eiusmod tempor incididunt</div>
<div   class="float">ut labore et dolore magna aliqua.</div>
<div   class="last float">Ut enim ad minim veniam</div>
clear: both

• Clearing your floats is necessary to
  resume vertical stacking

• It also has the effect of giving the
  parent a height & width

• You can assign “clear: left” and “clear:
  right,” but sticking to “clear: both” is
  simpler
Clearing the floats




<div class="float">Lorem ipsum dolor sit amet</div>
<div class="float">consectetur adipisicing elit,</div>
<div class="float">sed do eiusmod tempor incididunt</div>
<div class="float">ut labore et dolore magna aliqua.</div>
<div class="last float">Ut enim ad minim veniam</div>
<br class="clear" />
Floating left and right


          Note that b comes “before” a with float: right




<div class="left">&larr;     left a</div>
<div class="left">&larr;     left b</div>
<div class="right">right     a &rarr;</div>
<div class="right">right     b &rarr;</div>
<br class="clear" />

More Related Content

PPTX
Website trends 2012 presentation
PDF
CSS and Layout
KEY
The Future of HTML Motion Design
PPTX
CSS Stylesheet Training
PPTX
Chapter 17: Responsive Web Design
KEY
CSS and CSS3
PDF
Word press templates
PDF
Web tech 101
Website trends 2012 presentation
CSS and Layout
The Future of HTML Motion Design
CSS Stylesheet Training
Chapter 17: Responsive Web Design
CSS and CSS3
Word press templates
Web tech 101

Viewers also liked (6)

PDF
The web context
PDF
Intro to word press
PDF
Occupy.here
PDF
Intro to JavaScript
PDF
Diving into php
PDF
The Outcome Economy
The web context
Intro to word press
Occupy.here
Intro to JavaScript
Diving into php
The Outcome Economy
Ad

Similar to Static layouts with css (20)

PPTX
Lecture 6.pptx..........................
PPT
CSS for basic learner
PPT
Introduction to HTML
PDF
Web Layout
PPTX
Howcssworks 100207024009-phpapp01
PPT
Slice and Dice
KEY
Css Essential
PPTX
Advanced CSS.pptx
PPTX
Css intro
PPTX
CSS Layout Tutorial
PPT
W3Conf slides - The top web features from caniuse.com you can use today
PDF
Inline, Block and Positioning in CSS
PDF
HTML5 & CSS3 Flag
KEY
Trendsetting: Web Design and Beyond
PPTX
CSS tutorial chapter 3
PDF
Layout with CSS
PPTX
Web Development - Lecture 6
PPT
Web design-workflow
PPTX
css v1 guru
Lecture 6.pptx..........................
CSS for basic learner
Introduction to HTML
Web Layout
Howcssworks 100207024009-phpapp01
Slice and Dice
Css Essential
Advanced CSS.pptx
Css intro
CSS Layout Tutorial
W3Conf slides - The top web features from caniuse.com you can use today
Inline, Block and Positioning in CSS
HTML5 & CSS3 Flag
Trendsetting: Web Design and Beyond
CSS tutorial chapter 3
Layout with CSS
Web Development - Lecture 6
Web design-workflow
css v1 guru
Ad

Recently uploaded (20)

PDF
Advanced Soft Computing BINUS July 2025.pdf
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
PDF
Reimagining Insurance: Connected Data for Confident Decisions.pdf
PDF
DevOps & Developer Experience Summer BBQ
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PPTX
CroxyProxy Instagram Access id login.pptx
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Transforming Manufacturing operations through Intelligent Integrations
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
PDF
SAP855240_ALP - Defining the Global Template PUBLIC.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
PPTX
Big Data Technologies - Introduction.pptx
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Smarter Business Operations Powered by IoT Remote Monitoring
Advanced Soft Computing BINUS July 2025.pdf
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Reimagining Insurance: Connected Data for Confident Decisions.pdf
DevOps & Developer Experience Summer BBQ
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
CroxyProxy Instagram Access id login.pptx
GamePlan Trading System Review: Professional Trader's Honest Take
Chapter 3 Spatial Domain Image Processing.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
MYSQL Presentation for SQL database connectivity
Transforming Manufacturing operations through Intelligent Integrations
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
SAP855240_ALP - Defining the Global Template PUBLIC.pdf
20250228 LYD VKU AI Blended-Learning.pptx
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
Big Data Technologies - Introduction.pptx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Smarter Business Operations Powered by IoT Remote Monitoring

Static layouts with css

  • 1. Static layouts with CSS How to layout webpages using the display, float, clear, and properties
  • 2. CSS layout basics, in 10 slides
  • 3. CSS layout basics, in 10 slides
  • 4. display: inline • Used mostly for text, which “fills up” its container • Inline element types include span, a, strong, em, and (confusingly) img • New elements go on the same line, immediately after the previous one
  • 5. Inline span elements <span class="first">Lorem ipsum dolor ...</span> <span class="second">Ut enim ad minim veniam, ...</span>
  • 6. display: block • Structural elements that allow you to set width/height, margins, padding and borders • Block element types include div, p, form, h1, h2, h3, etc. • New elements stack vertically
  • 7. Block div elements <div class="first">Lorem ipsum dolor ...</div> <div class="second">Ut enim ad minim veniam, ...</div>
  • 8. CSS Box Model Block only • width, height • padding • Inline + block border • margin Diagram by Rich Hauck
  • 9. float: left, float: right • Floating causes block elements to stack horizontally • Elements keep stacking until the container width is filled • Additional elements are added below, much like inline content does
  • 10. Floated divs <div class="float">Lorem ipsum dolor sit amet</div> <div class="float">consectetur adipisicing elit,</div> <div class="float">sed do eiusmod tempor incididunt</div> <div class="float">ut labore et dolore magna aliqua.</div> <div class="last float">Ut enim ad minim veniam</div>
  • 11. clear: both • Clearing your floats is necessary to resume vertical stacking • It also has the effect of giving the parent a height & width • You can assign “clear: left” and “clear: right,” but sticking to “clear: both” is simpler
  • 12. Clearing the floats <div class="float">Lorem ipsum dolor sit amet</div> <div class="float">consectetur adipisicing elit,</div> <div class="float">sed do eiusmod tempor incididunt</div> <div class="float">ut labore et dolore magna aliqua.</div> <div class="last float">Ut enim ad minim veniam</div> <br class="clear" />
  • 13. Floating left and right Note that b comes “before” a with float: right <div class="left">&larr; left a</div> <div class="left">&larr; left b</div> <div class="right">right a &rarr;</div> <div class="right">right b &rarr;</div> <br class="clear" />