SlideShare a Scribd company logo
1 of 40
Laying out Elements with CSS
Objectives
Assess the CSS box model
Set element width and borders
Set margins and padding
Align elements with float
Control page flow with clear
HTML5 and CSS3 – Illustrated, 2nd Edition 2
Objectives (continued)
Implement fixed positioning
Implement relative positioning
Control stacking order
Implement absolute positioning
HTML5 and CSS3 – Illustrated, 2nd Edition 3
Assess the CSS Box Model
Box model: used by CSS to represent
characteristics of every web page
element
 Treats element as rectangular box
border: border surrounding element
margin: space from border to
neighboring/parent element
padding: space between border and
element content
HTML5 and CSS3 – Illustrated, 2nd Edition 4
Assess the CSS Box Model
(continued)
The CSS box model
HTML5 and CSS3 – Illustrated, 2nd Edition 5
Assess the CSS Box Model
(continued)
Box model properties
HTML5 and CSS3 – Illustrated, 2nd Edition 6
Assess the CSS Box Model
(continued)
CSS units of measure
 Relative units: ems, percent, rems
 Absolute units: pixels
Commonly used CSS units of
measure
HTML5 and CSS3 – Illustrated, 2nd Edition 7
Assess the CSS Box Model
(continued)
Size of padding, margin, and
border increase the amount of space
occupied by an element
 Dimensions of these properties not
included in specified width / height
• Specified width and height refer only to the
content of an element
• To calculate add the total space, add the
width value to the padding, margin, and
border values
HTML5 and CSS3 – Illustrated, 2nd Edition 8
Assess the CSS Box Model
(continued)
Calculating web page space occupied
by an element
HTML5 and CSS3 – Illustrated, 2nd Edition 9
Assess the CSS Box Model
(continued)
Collapse: When bottom margin of one
element is adjacent to top margin of
another, the margins combine to the
size of the larger of the two
 Affects element size planning
Separate property for each side of
padding and margin, e.g.
 padding-top: 2px;
 margin-right: 1em;
HTML5 and CSS3 – Illustrated, 2nd Edition 10
Set Element Width
and Borders
Margin, padding, and border are
shorthand properties
 Assign values to multiple CSS properties
 Assign values to all four sides of an
element
 Assign these values using a single
declaration
Can set width, style, or color of any or
all sides of an element
HTML5 and CSS3 – Illustrated, 2nd Edition 11
Set Element Width
and Borders (continued)
Specific properties for the box model
Reset rule: resets one or more
common properties to a common
baseline, e.g.
 border: 0
HTML5 and CSS3 – Illustrated, 2nd Edition 12
Set Element Width
and Borders (continued)
Code with width and border
declarations
HTML5 and CSS3 – Illustrated, 2nd Edition 13
Set Element Width
and Borders (continued)
width and border declarations
rendered in a browser and developer
tools opened to show box model
HTML5 and CSS3 – Illustrated, 2nd Edition 14
Set Margins and Padding
Use the shorthand property to assign
multiple values
 Separate each value with a space
 Meaning of different number of values
Assign auto to left and right margins
to center the element horizontally
HTML5 and CSS3 – Illustrated, 2nd Edition 15
Set Margins and Padding
(continued)
Example of padding using three
values and margin using two values
Example of margin set to auto
HTML5 and CSS3 – Illustrated, 2nd Edition 16
Align Elements with float
Page flow: the order of elements in the
HTML document
 User agents render HTML top to bottom
 Easy to create layouts with elements
stacked vertically
Use float, clear, and width
properties to create columns of text
and graphics parallel to each other
 Use width property to assign width to
each of the columns
HTML5 and CSS3 – Illustrated, 2nd Edition 17
Align Elements with float
(continued)
Example of float applied to element
Use float to create multicolumn
layoutsHTML5 and CSS3 – Illustrated, 2nd Edition 18
Align Elements with float
(continued)
Code with float and result in browser
HTML5 and CSS3 – Illustrated, 2nd Edition 19
Control Page Flow
with clear
float gives basic control over layout
clear gives more precise control
 Prevents floated elements from being
displayed to the left, right, or on the side
of another element
clear property values
HTML5 and CSS3 – Illustrated, 2nd Edition 20
Control Page Flow with clear
(continued)
Example of clear property
HTML5 and CSS3 – Illustrated, 2nd Edition 21
Control Page Flow with clear
(continued)
Code including clear property and
how it is rendered in a browser
HTML5 and CSS3 – Illustrated, 2nd Edition 22
Implement Fixed
Positioning
fixed positioning keeps an element
in the same location, even when the
page is scrolled
Use the position property with the
value of fixed
Then specify
 Horizontal position using left or right
 Vertical positing using top or bottom
HTML5 and CSS3 – Illustrated, 2nd Edition 23
Implement Fixed Positioning
(continued)
Commonly used position properties
Properties and values for fixed
positioning
HTML5 and CSS3 – Illustrated, 2nd Edition 24
Implement Fixed Positioning
(continued)
Example showing fixed positioning
HTML5 and CSS3 – Illustrated, 2nd Edition 25
Implement Fixed Positioning
(continued)
Code including fixed value and how
it is rendered in a browser
HTML5 and CSS3 – Illustrated, 2nd Edition 26
Implement Relative
Positioning
Relative positioning: adjusting default
position of an element
 Preserves space allotted to element in
default page flow
 Set position property to relative
 Style exact location using the properties
•left and right for horizontal positioning
•top and bottom for vertical positioning
HTML5 and CSS3 – Illustrated, 2nd Edition 27
Implement Relative
Positioning (continued)
CSS properties and values for relative
positioning
HTML5 and CSS3 – Illustrated, 2nd Edition 28
Implement Relative
Positioning (continued)
Implementing relative positioning and
page flow
HTML5 and CSS3 – Illustrated, 2nd Edition 29
Implement Relative
Positioning (continued)
Code using relative positioning and
how it is rendered in a browser
HTML5 and CSS3 – Illustrated, 2nd Edition 30
Control stacking order
Stacking elements: positioning
elements so that they can overlap
 Additional possibilities for layouts
 Applies only to positioned element
 Elements placed in new layer
 Requires careful planning
Stacking order controlled by values
assigned to z-index property
HTML5 and CSS3 – Illustrated, 2nd Edition 31
Control Stacking Order
(continued)
Stacking positioned elements
HTML5 and CSS3 – Illustrated, 2nd Edition 32
Control Stacking Order
(continued)
Code to stack and how it is
rendered in a browser
HTML5 and CSS3 – Illustrated, 2nd Edition 33
Implement Absolute
Positioning
Absolute positioning: takes element
out of page flow entirely
 Allows other elements to flow into space
element would have occupied
 Set position property to absolute
 Style exact location using left, right,
top, and bottom properties
 Location is calculated relative to closest
ancestor element that has position
applied to it
HTML5 and CSS3 – Illustrated, 2nd Edition 34
Implement Absolute
Positioning (continued)
Absolute positioning and page flow
Properties and values
HTML5 and CSS3 – Illustrated, 2nd Edition 35
Implement Absolute
Positioning (continued)
Code to absolutely position an
element and the result in a browser
HTML5 and CSS3 – Illustrated, 2nd Edition 36
Summary
Box model: used by CSS to represent
characteristics of elements
 Treats element as rectangular box
 Defines border, margin and padding
Margins of adjacent elements can
collapse into one margin
Specify border width, style,
and/or color of any or all sides
HTML5 and CSS3 – Illustrated, 2nd Edition 37
Summary (continued)
Use multiple values to assign margin
and padding values to different sides
Use float to change the default
page flow
Use clear to create a more precise
layout
Use float, clear and width to
create multicolumn layouts
HTML5 and CSS3 – Illustrated, 2nd Edition 38
Summary (continued)
Fixed positioning: keeps an element in
the same position, even when the
page is scrolled
Relative positioning: adjusting location
of element relative to its page flow
location using position property
 Space preserved
HTML5 and CSS3 – Illustrated, 2nd Edition 39
Summary (continued)
Use z-index to create a stacking
order for elements
 Stacked elements are placed in new
layers
Absolute positioning: takes elements
out of page flow entirely
 Other elements reflow into empty space
HTML5 and CSS3 – Illustrated, 2nd Edition 40

More Related Content

What's hot

Getting Started with CSS
Getting Started with CSSGetting Started with CSS
Getting Started with CSSNicole Ryan
 
Working with Video and Audio
Working with Video and AudioWorking with Video and Audio
Working with Video and AudioNicole Ryan
 
Optimizing a website for search engines
Optimizing a website for search enginesOptimizing a website for search engines
Optimizing a website for search enginesNicole Ryan
 
Social media and your website
Social media and your websiteSocial media and your website
Social media and your websiteNicole Ryan
 
Crystal report
Crystal reportCrystal report
Crystal reportEverywhere
 
Crystal report generation in visual studio 2010
Crystal report generation in visual studio 2010Crystal report generation in visual studio 2010
Crystal report generation in visual studio 2010Slideshare
 
Quickstart Microsoft access 2013
Quickstart Microsoft access 2013Quickstart Microsoft access 2013
Quickstart Microsoft access 2013comatsg
 
New Features of HTML 5.1 to Create More Flexible Web Experiences
New Features of HTML 5.1 to Create More Flexible Web ExperiencesNew Features of HTML 5.1 to Create More Flexible Web Experiences
New Features of HTML 5.1 to Create More Flexible Web ExperiencesRasin Bekkevold
 
Introduction To Flex
Introduction To FlexIntroduction To Flex
Introduction To FlexYoss Cohen
 
Liquidlayout
LiquidlayoutLiquidlayout
Liquidlayoutsammt
 
Content Architecture
Content ArchitectureContent Architecture
Content ArchitectureDara Pressley
 
Access 2013 Unit A
Access 2013 Unit AAccess 2013 Unit A
Access 2013 Unit Ajarana00
 
Psd to html
Psd to htmlPsd to html
Psd to htmlLen Biel
 

What's hot (17)

Getting Started with CSS
Getting Started with CSSGetting Started with CSS
Getting Started with CSS
 
Working with Video and Audio
Working with Video and AudioWorking with Video and Audio
Working with Video and Audio
 
Optimizing a website for search engines
Optimizing a website for search enginesOptimizing a website for search engines
Optimizing a website for search engines
 
Social media and your website
Social media and your websiteSocial media and your website
Social media and your website
 
Crystal report
Crystal reportCrystal report
Crystal report
 
C# Crystal Reports
C# Crystal ReportsC# Crystal Reports
C# Crystal Reports
 
Crystal report
Crystal reportCrystal report
Crystal report
 
Crystal report generation in visual studio 2010
Crystal report generation in visual studio 2010Crystal report generation in visual studio 2010
Crystal report generation in visual studio 2010
 
Quickstart Microsoft access 2013
Quickstart Microsoft access 2013Quickstart Microsoft access 2013
Quickstart Microsoft access 2013
 
New Features of HTML 5.1 to Create More Flexible Web Experiences
New Features of HTML 5.1 to Create More Flexible Web ExperiencesNew Features of HTML 5.1 to Create More Flexible Web Experiences
New Features of HTML 5.1 to Create More Flexible Web Experiences
 
M02 un12 p01
M02 un12 p01M02 un12 p01
M02 un12 p01
 
Introduction To Flex
Introduction To FlexIntroduction To Flex
Introduction To Flex
 
Dreamweaver Ch03
Dreamweaver Ch03Dreamweaver Ch03
Dreamweaver Ch03
 
Liquidlayout
LiquidlayoutLiquidlayout
Liquidlayout
 
Content Architecture
Content ArchitectureContent Architecture
Content Architecture
 
Access 2013 Unit A
Access 2013 Unit AAccess 2013 Unit A
Access 2013 Unit A
 
Psd to html
Psd to htmlPsd to html
Psd to html
 

Viewers also liked

Organizing Content with Lists and Tables
Organizing Content with Lists and TablesOrganizing Content with Lists and Tables
Organizing Content with Lists and TablesNicole Ryan
 
Creating and Processing Web Forms
Creating and Processing Web FormsCreating and Processing Web Forms
Creating and Processing Web FormsNicole Ryan
 
Microsoft TechDays - CSS3 Presentation
Microsoft TechDays - CSS3 PresentationMicrosoft TechDays - CSS3 Presentation
Microsoft TechDays - CSS3 PresentationRachel Andrew
 
Tutorial: Html5 And Css3 Site
Tutorial: Html5 And Css3 SiteTutorial: Html5 And Css3 Site
Tutorial: Html5 And Css3 SiteAdam Stewart
 
CSS3 - is everything we used to do wrong?
CSS3 - is everything we used to do wrong? CSS3 - is everything we used to do wrong?
CSS3 - is everything we used to do wrong? Russ Weakley
 
Maintainable CSS
Maintainable CSSMaintainable CSS
Maintainable CSSStephen Hay
 
Everything You know about CSS is Wrong
Everything You know about CSS is WrongEverything You know about CSS is Wrong
Everything You know about CSS is Wrongchandleryu
 
Presentación Multimedia - HTML5
Presentación Multimedia - HTML5Presentación Multimedia - HTML5
Presentación Multimedia - HTML5Viviana Trujillo
 
Techdays 2012 - Développement Web Mobile avec Microsoft
Techdays 2012 - Développement Web Mobile avec MicrosoftTechdays 2012 - Développement Web Mobile avec Microsoft
Techdays 2012 - Développement Web Mobile avec Microsoftwyggio
 
ตัวอย่าง Workshop basic html5 and css3 จากไอทีจีเนียส
ตัวอย่าง Workshop basic html5 and css3 จากไอทีจีเนียสตัวอย่าง Workshop basic html5 and css3 จากไอทีจีเนียส
ตัวอย่าง Workshop basic html5 and css3 จากไอทีจีเนียสSamit Koyom
 
The Future State of Layout
The Future State of LayoutThe Future State of Layout
The Future State of LayoutStephen Hay
 
CSS: a rapidly changing world
CSS: a rapidly changing worldCSS: a rapidly changing world
CSS: a rapidly changing worldRuss Weakley
 
Efficient, maintainable CSS
Efficient, maintainable CSSEfficient, maintainable CSS
Efficient, maintainable CSSRuss Weakley
 
CSS3: A practical introduction (FT2010 talk)
CSS3: A practical introduction (FT2010 talk)CSS3: A practical introduction (FT2010 talk)
CSS3: A practical introduction (FT2010 talk)Lea Verou
 
CSS Layouting #4 : Float
CSS Layouting #4 : FloatCSS Layouting #4 : Float
CSS Layouting #4 : FloatSandhika Galih
 
CSS Box Model Presentation
CSS Box Model PresentationCSS Box Model Presentation
CSS Box Model PresentationReed Crouch
 
CSS3 secrets: 10 things you might not know about CSS3
CSS3 secrets: 10 things you might not know about CSS3CSS3 secrets: 10 things you might not know about CSS3
CSS3 secrets: 10 things you might not know about CSS3Lea Verou
 
Conoce HTML5 y CSS3
Conoce HTML5 y CSS3Conoce HTML5 y CSS3
Conoce HTML5 y CSS3Marta Armada
 

Viewers also liked (20)

Organizing Content with Lists and Tables
Organizing Content with Lists and TablesOrganizing Content with Lists and Tables
Organizing Content with Lists and Tables
 
Creating and Processing Web Forms
Creating and Processing Web FormsCreating and Processing Web Forms
Creating and Processing Web Forms
 
Microsoft TechDays - CSS3 Presentation
Microsoft TechDays - CSS3 PresentationMicrosoft TechDays - CSS3 Presentation
Microsoft TechDays - CSS3 Presentation
 
Tutorial: Html5 And Css3 Site
Tutorial: Html5 And Css3 SiteTutorial: Html5 And Css3 Site
Tutorial: Html5 And Css3 Site
 
CSS3 - is everything we used to do wrong?
CSS3 - is everything we used to do wrong? CSS3 - is everything we used to do wrong?
CSS3 - is everything we used to do wrong?
 
Maintainable CSS
Maintainable CSSMaintainable CSS
Maintainable CSS
 
Everything You know about CSS is Wrong
Everything You know about CSS is WrongEverything You know about CSS is Wrong
Everything You know about CSS is Wrong
 
HTML5 Quick Start
HTML5 Quick StartHTML5 Quick Start
HTML5 Quick Start
 
Presentación Multimedia - HTML5
Presentación Multimedia - HTML5Presentación Multimedia - HTML5
Presentación Multimedia - HTML5
 
Techdays 2012 - Développement Web Mobile avec Microsoft
Techdays 2012 - Développement Web Mobile avec MicrosoftTechdays 2012 - Développement Web Mobile avec Microsoft
Techdays 2012 - Développement Web Mobile avec Microsoft
 
ตัวอย่าง Workshop basic html5 and css3 จากไอทีจีเนียส
ตัวอย่าง Workshop basic html5 and css3 จากไอทีจีเนียสตัวอย่าง Workshop basic html5 and css3 จากไอทีจีเนียส
ตัวอย่าง Workshop basic html5 and css3 จากไอทีจีเนียส
 
The Future State of Layout
The Future State of LayoutThe Future State of Layout
The Future State of Layout
 
Css floats
Css floatsCss floats
Css floats
 
CSS: a rapidly changing world
CSS: a rapidly changing worldCSS: a rapidly changing world
CSS: a rapidly changing world
 
Efficient, maintainable CSS
Efficient, maintainable CSSEfficient, maintainable CSS
Efficient, maintainable CSS
 
CSS3: A practical introduction (FT2010 talk)
CSS3: A practical introduction (FT2010 talk)CSS3: A practical introduction (FT2010 talk)
CSS3: A practical introduction (FT2010 talk)
 
CSS Layouting #4 : Float
CSS Layouting #4 : FloatCSS Layouting #4 : Float
CSS Layouting #4 : Float
 
CSS Box Model Presentation
CSS Box Model PresentationCSS Box Model Presentation
CSS Box Model Presentation
 
CSS3 secrets: 10 things you might not know about CSS3
CSS3 secrets: 10 things you might not know about CSS3CSS3 secrets: 10 things you might not know about CSS3
CSS3 secrets: 10 things you might not know about CSS3
 
Conoce HTML5 y CSS3
Conoce HTML5 y CSS3Conoce HTML5 y CSS3
Conoce HTML5 y CSS3
 

Similar to Laying out Elements with CSS

Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvvZahouAmel1
 
UNIT-III-Chapter 6 [Autosaved].pptx
UNIT-III-Chapter 6 [Autosaved].pptxUNIT-III-Chapter 6 [Autosaved].pptx
UNIT-III-Chapter 6 [Autosaved].pptx2BA19CS016BharatiJad
 
Cordova training - Day 2 Introduction to CSS 3
Cordova training - Day 2 Introduction to CSS 3Cordova training - Day 2 Introduction to CSS 3
Cordova training - Day 2 Introduction to CSS 3Binu Paul
 
Build a better UI component library with Styled System
Build a better UI component library with Styled SystemBuild a better UI component library with Styled System
Build a better UI component library with Styled SystemHsin-Hao Tang
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksAmit Tyagi
 
3 css essentials
3 css essentials3 css essentials
3 css essentialsAnchu S
 
Designing for the web - 101
Designing for the web - 101Designing for the web - 101
Designing for the web - 101Ashraf Hamdy
 
3-CSS_essentials.ppt
3-CSS_essentials.ppt3-CSS_essentials.ppt
3-CSS_essentials.pptdatapro2
 
3-CSS_essentials_developers_begineers.ppt
3-CSS_essentials_developers_begineers.ppt3-CSS_essentials_developers_begineers.ppt
3-CSS_essentials_developers_begineers.pptmohamed abd elrazek
 
3-CSS_essentials.ppt
3-CSS_essentials.ppt3-CSS_essentials.ppt
3-CSS_essentials.pptscet315
 
Css layouts-continued
Css layouts-continuedCss layouts-continued
Css layouts-continuedhuia
 
Cordova training - Day 3 : Advanced CSS 3
Cordova training - Day 3 : Advanced CSS 3Cordova training - Day 3 : Advanced CSS 3
Cordova training - Day 3 : Advanced CSS 3Binu Paul
 

Similar to Laying out Elements with CSS (20)

Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
 
Lecture-8.pptx
Lecture-8.pptxLecture-8.pptx
Lecture-8.pptx
 
CSS3 PPT.pptx
CSS3 PPT.pptxCSS3 PPT.pptx
CSS3 PPT.pptx
 
Css
CssCss
Css
 
UNIT-III-Chapter 6 [Autosaved].pptx
UNIT-III-Chapter 6 [Autosaved].pptxUNIT-III-Chapter 6 [Autosaved].pptx
UNIT-III-Chapter 6 [Autosaved].pptx
 
Cordova training - Day 2 Introduction to CSS 3
Cordova training - Day 2 Introduction to CSS 3Cordova training - Day 2 Introduction to CSS 3
Cordova training - Day 2 Introduction to CSS 3
 
CSS
CSSCSS
CSS
 
Introduction to CSS3
Introduction to CSS3Introduction to CSS3
Introduction to CSS3
 
Css
CssCss
Css
 
CSS
CSSCSS
CSS
 
Build a better UI component library with Styled System
Build a better UI component library with Styled SystemBuild a better UI component library with Styled System
Build a better UI component library with Styled System
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
 
A complete guide to flexbox
A complete guide to flexboxA complete guide to flexbox
A complete guide to flexbox
 
3 css essentials
3 css essentials3 css essentials
3 css essentials
 
Designing for the web - 101
Designing for the web - 101Designing for the web - 101
Designing for the web - 101
 
3-CSS_essentials.ppt
3-CSS_essentials.ppt3-CSS_essentials.ppt
3-CSS_essentials.ppt
 
3-CSS_essentials_developers_begineers.ppt
3-CSS_essentials_developers_begineers.ppt3-CSS_essentials_developers_begineers.ppt
3-CSS_essentials_developers_begineers.ppt
 
3-CSS_essentials.ppt
3-CSS_essentials.ppt3-CSS_essentials.ppt
3-CSS_essentials.ppt
 
Css layouts-continued
Css layouts-continuedCss layouts-continued
Css layouts-continued
 
Cordova training - Day 3 : Advanced CSS 3
Cordova training - Day 3 : Advanced CSS 3Cordova training - Day 3 : Advanced CSS 3
Cordova training - Day 3 : Advanced CSS 3
 

More from Nicole Ryan

Python Dictionaries and Sets
Python Dictionaries and SetsPython Dictionaries and Sets
Python Dictionaries and SetsNicole Ryan
 
Chapter 12 Lecture: GUI Programming, Multithreading, and Animation
Chapter 12 Lecture: GUI Programming, Multithreading, and AnimationChapter 12 Lecture: GUI Programming, Multithreading, and Animation
Chapter 12 Lecture: GUI Programming, Multithreading, and AnimationNicole Ryan
 
Chapter 11: Object Oriented Programming Part 2
Chapter 11: Object Oriented Programming Part 2Chapter 11: Object Oriented Programming Part 2
Chapter 11: Object Oriented Programming Part 2Nicole Ryan
 
Intro to Programming: Modularity
Intro to Programming: ModularityIntro to Programming: Modularity
Intro to Programming: ModularityNicole Ryan
 
Programming Logic and Design: Arrays
Programming Logic and Design: ArraysProgramming Logic and Design: Arrays
Programming Logic and Design: ArraysNicole Ryan
 
Programming Logic and Design: Working with Data
Programming Logic and Design: Working with DataProgramming Logic and Design: Working with Data
Programming Logic and Design: Working with DataNicole Ryan
 
Setting up your development environment
Setting up your development environmentSetting up your development environment
Setting up your development environmentNicole Ryan
 
Dynamic vs static
Dynamic vs staticDynamic vs static
Dynamic vs staticNicole Ryan
 
Working with Databases and MySQL
Working with Databases and MySQLWorking with Databases and MySQL
Working with Databases and MySQLNicole Ryan
 
Using arrays with PHP for forms and storing information
Using arrays with PHP for forms and storing informationUsing arrays with PHP for forms and storing information
Using arrays with PHP for forms and storing informationNicole Ryan
 
Tables and forms accessibility and microformats
Tables and forms accessibility and microformatsTables and forms accessibility and microformats
Tables and forms accessibility and microformatsNicole Ryan
 
Creating and styling forms
Creating and styling formsCreating and styling forms
Creating and styling formsNicole Ryan
 
Creating and styling tables
Creating and styling tablesCreating and styling tables
Creating and styling tablesNicole Ryan
 
Files and Directories in PHP
Files and Directories in PHPFiles and Directories in PHP
Files and Directories in PHPNicole Ryan
 
Handling User Input and Processing Form Data
Handling User Input and Processing Form DataHandling User Input and Processing Form Data
Handling User Input and Processing Form DataNicole Ryan
 

More from Nicole Ryan (16)

Inheritance
InheritanceInheritance
Inheritance
 
Python Dictionaries and Sets
Python Dictionaries and SetsPython Dictionaries and Sets
Python Dictionaries and Sets
 
Chapter 12 Lecture: GUI Programming, Multithreading, and Animation
Chapter 12 Lecture: GUI Programming, Multithreading, and AnimationChapter 12 Lecture: GUI Programming, Multithreading, and Animation
Chapter 12 Lecture: GUI Programming, Multithreading, and Animation
 
Chapter 11: Object Oriented Programming Part 2
Chapter 11: Object Oriented Programming Part 2Chapter 11: Object Oriented Programming Part 2
Chapter 11: Object Oriented Programming Part 2
 
Intro to Programming: Modularity
Intro to Programming: ModularityIntro to Programming: Modularity
Intro to Programming: Modularity
 
Programming Logic and Design: Arrays
Programming Logic and Design: ArraysProgramming Logic and Design: Arrays
Programming Logic and Design: Arrays
 
Programming Logic and Design: Working with Data
Programming Logic and Design: Working with DataProgramming Logic and Design: Working with Data
Programming Logic and Design: Working with Data
 
Setting up your development environment
Setting up your development environmentSetting up your development environment
Setting up your development environment
 
Dynamic vs static
Dynamic vs staticDynamic vs static
Dynamic vs static
 
Working with Databases and MySQL
Working with Databases and MySQLWorking with Databases and MySQL
Working with Databases and MySQL
 
Using arrays with PHP for forms and storing information
Using arrays with PHP for forms and storing informationUsing arrays with PHP for forms and storing information
Using arrays with PHP for forms and storing information
 
Tables and forms accessibility and microformats
Tables and forms accessibility and microformatsTables and forms accessibility and microformats
Tables and forms accessibility and microformats
 
Creating and styling forms
Creating and styling formsCreating and styling forms
Creating and styling forms
 
Creating and styling tables
Creating and styling tablesCreating and styling tables
Creating and styling tables
 
Files and Directories in PHP
Files and Directories in PHPFiles and Directories in PHP
Files and Directories in PHP
 
Handling User Input and Processing Form Data
Handling User Input and Processing Form DataHandling User Input and Processing Form Data
Handling User Input and Processing Form Data
 

Recently uploaded

Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
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
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 

Recently uploaded (20)

Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
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
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 

Laying out Elements with CSS

  • 2. Objectives Assess the CSS box model Set element width and borders Set margins and padding Align elements with float Control page flow with clear HTML5 and CSS3 – Illustrated, 2nd Edition 2
  • 3. Objectives (continued) Implement fixed positioning Implement relative positioning Control stacking order Implement absolute positioning HTML5 and CSS3 – Illustrated, 2nd Edition 3
  • 4. Assess the CSS Box Model Box model: used by CSS to represent characteristics of every web page element  Treats element as rectangular box border: border surrounding element margin: space from border to neighboring/parent element padding: space between border and element content HTML5 and CSS3 – Illustrated, 2nd Edition 4
  • 5. Assess the CSS Box Model (continued) The CSS box model HTML5 and CSS3 – Illustrated, 2nd Edition 5
  • 6. Assess the CSS Box Model (continued) Box model properties HTML5 and CSS3 – Illustrated, 2nd Edition 6
  • 7. Assess the CSS Box Model (continued) CSS units of measure  Relative units: ems, percent, rems  Absolute units: pixels Commonly used CSS units of measure HTML5 and CSS3 – Illustrated, 2nd Edition 7
  • 8. Assess the CSS Box Model (continued) Size of padding, margin, and border increase the amount of space occupied by an element  Dimensions of these properties not included in specified width / height • Specified width and height refer only to the content of an element • To calculate add the total space, add the width value to the padding, margin, and border values HTML5 and CSS3 – Illustrated, 2nd Edition 8
  • 9. Assess the CSS Box Model (continued) Calculating web page space occupied by an element HTML5 and CSS3 – Illustrated, 2nd Edition 9
  • 10. Assess the CSS Box Model (continued) Collapse: When bottom margin of one element is adjacent to top margin of another, the margins combine to the size of the larger of the two  Affects element size planning Separate property for each side of padding and margin, e.g.  padding-top: 2px;  margin-right: 1em; HTML5 and CSS3 – Illustrated, 2nd Edition 10
  • 11. Set Element Width and Borders Margin, padding, and border are shorthand properties  Assign values to multiple CSS properties  Assign values to all four sides of an element  Assign these values using a single declaration Can set width, style, or color of any or all sides of an element HTML5 and CSS3 – Illustrated, 2nd Edition 11
  • 12. Set Element Width and Borders (continued) Specific properties for the box model Reset rule: resets one or more common properties to a common baseline, e.g.  border: 0 HTML5 and CSS3 – Illustrated, 2nd Edition 12
  • 13. Set Element Width and Borders (continued) Code with width and border declarations HTML5 and CSS3 – Illustrated, 2nd Edition 13
  • 14. Set Element Width and Borders (continued) width and border declarations rendered in a browser and developer tools opened to show box model HTML5 and CSS3 – Illustrated, 2nd Edition 14
  • 15. Set Margins and Padding Use the shorthand property to assign multiple values  Separate each value with a space  Meaning of different number of values Assign auto to left and right margins to center the element horizontally HTML5 and CSS3 – Illustrated, 2nd Edition 15
  • 16. Set Margins and Padding (continued) Example of padding using three values and margin using two values Example of margin set to auto HTML5 and CSS3 – Illustrated, 2nd Edition 16
  • 17. Align Elements with float Page flow: the order of elements in the HTML document  User agents render HTML top to bottom  Easy to create layouts with elements stacked vertically Use float, clear, and width properties to create columns of text and graphics parallel to each other  Use width property to assign width to each of the columns HTML5 and CSS3 – Illustrated, 2nd Edition 17
  • 18. Align Elements with float (continued) Example of float applied to element Use float to create multicolumn layoutsHTML5 and CSS3 – Illustrated, 2nd Edition 18
  • 19. Align Elements with float (continued) Code with float and result in browser HTML5 and CSS3 – Illustrated, 2nd Edition 19
  • 20. Control Page Flow with clear float gives basic control over layout clear gives more precise control  Prevents floated elements from being displayed to the left, right, or on the side of another element clear property values HTML5 and CSS3 – Illustrated, 2nd Edition 20
  • 21. Control Page Flow with clear (continued) Example of clear property HTML5 and CSS3 – Illustrated, 2nd Edition 21
  • 22. Control Page Flow with clear (continued) Code including clear property and how it is rendered in a browser HTML5 and CSS3 – Illustrated, 2nd Edition 22
  • 23. Implement Fixed Positioning fixed positioning keeps an element in the same location, even when the page is scrolled Use the position property with the value of fixed Then specify  Horizontal position using left or right  Vertical positing using top or bottom HTML5 and CSS3 – Illustrated, 2nd Edition 23
  • 24. Implement Fixed Positioning (continued) Commonly used position properties Properties and values for fixed positioning HTML5 and CSS3 – Illustrated, 2nd Edition 24
  • 25. Implement Fixed Positioning (continued) Example showing fixed positioning HTML5 and CSS3 – Illustrated, 2nd Edition 25
  • 26. Implement Fixed Positioning (continued) Code including fixed value and how it is rendered in a browser HTML5 and CSS3 – Illustrated, 2nd Edition 26
  • 27. Implement Relative Positioning Relative positioning: adjusting default position of an element  Preserves space allotted to element in default page flow  Set position property to relative  Style exact location using the properties •left and right for horizontal positioning •top and bottom for vertical positioning HTML5 and CSS3 – Illustrated, 2nd Edition 27
  • 28. Implement Relative Positioning (continued) CSS properties and values for relative positioning HTML5 and CSS3 – Illustrated, 2nd Edition 28
  • 29. Implement Relative Positioning (continued) Implementing relative positioning and page flow HTML5 and CSS3 – Illustrated, 2nd Edition 29
  • 30. Implement Relative Positioning (continued) Code using relative positioning and how it is rendered in a browser HTML5 and CSS3 – Illustrated, 2nd Edition 30
  • 31. Control stacking order Stacking elements: positioning elements so that they can overlap  Additional possibilities for layouts  Applies only to positioned element  Elements placed in new layer  Requires careful planning Stacking order controlled by values assigned to z-index property HTML5 and CSS3 – Illustrated, 2nd Edition 31
  • 32. Control Stacking Order (continued) Stacking positioned elements HTML5 and CSS3 – Illustrated, 2nd Edition 32
  • 33. Control Stacking Order (continued) Code to stack and how it is rendered in a browser HTML5 and CSS3 – Illustrated, 2nd Edition 33
  • 34. Implement Absolute Positioning Absolute positioning: takes element out of page flow entirely  Allows other elements to flow into space element would have occupied  Set position property to absolute  Style exact location using left, right, top, and bottom properties  Location is calculated relative to closest ancestor element that has position applied to it HTML5 and CSS3 – Illustrated, 2nd Edition 34
  • 35. Implement Absolute Positioning (continued) Absolute positioning and page flow Properties and values HTML5 and CSS3 – Illustrated, 2nd Edition 35
  • 36. Implement Absolute Positioning (continued) Code to absolutely position an element and the result in a browser HTML5 and CSS3 – Illustrated, 2nd Edition 36
  • 37. Summary Box model: used by CSS to represent characteristics of elements  Treats element as rectangular box  Defines border, margin and padding Margins of adjacent elements can collapse into one margin Specify border width, style, and/or color of any or all sides HTML5 and CSS3 – Illustrated, 2nd Edition 37
  • 38. Summary (continued) Use multiple values to assign margin and padding values to different sides Use float to change the default page flow Use clear to create a more precise layout Use float, clear and width to create multicolumn layouts HTML5 and CSS3 – Illustrated, 2nd Edition 38
  • 39. Summary (continued) Fixed positioning: keeps an element in the same position, even when the page is scrolled Relative positioning: adjusting location of element relative to its page flow location using position property  Space preserved HTML5 and CSS3 – Illustrated, 2nd Edition 39
  • 40. Summary (continued) Use z-index to create a stacking order for elements  Stacked elements are placed in new layers Absolute positioning: takes elements out of page flow entirely  Other elements reflow into empty space HTML5 and CSS3 – Illustrated, 2nd Edition 40