SlideShare a Scribd company logo
Lecture 2 : CSS III SFDV2001 Web Development
Page layout with CSS Tables, though still heavily used by web designers to control page layout, were never intended for that purpose. Ideally tables should be used for data only. As browsers become better at supporting web standards and as users of the web adopt those browsers, layout controlled entirely by CSS is becoming an increasingly realistic option. Even when table layout is still necessary, CSS streamlines their use, and makes your code much cleaner.
Standard document flow When no layout control is implemented for an HTML page, elements flow from top to bottom, left to right: Block-level elements produce a line break that sees subsequent block-level elements come beneath them.  Inline elements come one after the other, left to right, in the order they appear. The order sequence is determined by the tag sequence in your HTML. When you expand or contract the browser window, block-level elements alter to fit the new width.
Standard document flow When you position elements with CSS you can remove an element from the normal flow. Order your HTML sensibly so that someone accessing it without style information can make sense of it: Title Navigation Main content Footer That order won’t affect what you can achieve with CSS with regard to layout.
Float In Transitional HTML we could align an image to the right and have text wrap around it on the left using the align attribute. In CSS such behaviour is not limited to images. You can float any element. ul#nav{ float: left; }
Clear Just as we had the  clear  attribute of  <br>  in transitional HTML to stop text from sitting beside an aligned image when we didn’t want it to, so we have  clear  to accompany  float  in CSS. The  clear  attribute of  <br>  had the possible values:  left ,  right  or  all . In CSS  clear  gets:  left ,  right ,  both ,  none  or  inherit . The  clear  property can only be applied to block-level elements.
Position There are a number of different values of  position  in CSS: Static Relative Absolute Fixed Static  is the normal (default) position of elements on your page. Elements conform to the standard document flow. Position (and any of its values) can apply to any element.
Position Once you have determined what kind of positioning an element will employ (relative, absolute or fixed), the actual positioning is done via four properties: Top Right Bottom Left The values of these properties can be a length or a percentage. Top  position refers to an elements distance  from  the top (the top of what depends on what kind of positioning you are employing).
position: relative; Relative positioning moves an element from its place in the standard document flow but retains the space where it came from: position: relative; top: 40px; left: 40px; 40 40
position: absolute; Absolute positioning moves an element from its place in the standard document flow and closes the space where it came from. An element is positioned absolutely with relation to its nearest parent element that isn’t statically positioned. position: absolute; top: 40px; left: 40px; 40 40
position: fixed; Like absolute positioning, fixed positioning removes an element from the standard document flow, but instead of being fixed relative to its parent element it is fixed in relation to the view-port (normally the browser window). Can be useful to recreate frame like behaviour where a navigation menu can stay fixed while the rest of the content scrolls. Not as well supported as relative and absolute positioning.
Position Combinations Relative and absolutely positioned elements in particular can be combined to give your layout greater flexibility. An absolutely positioned element inside a relative element is positioned absolutely with respect to that relatively positioned parent. So the parent may be flexible but the child always stays in the same place in relation to it. Time for an example I think.
CSS and tables Please don’t get the message “tables are evil”. Tables should absolutely be used for tabular data:
CSS and tables And they are still necessary for some layout purposes. Complex forms are still easier to control with a table than CSS (and in many instances the form information fits the tabular data description). When you have to use a table for layout control keep it as clean as possible; use your CSS to style it. Things like empty cells, though there were never very many good excuses for them, should be rare with CSS. Combining CSS and tables for layout can be more of a headache than using CSS alone, so don’t think you’re taking the easy route.
Learn by example And by practice. Lots and lots of practice. You could sit in a thousand lectures, read a thousand articles and still not really “get” CSS. You absolutely must practice it: work out how things do what they do through experiment. There is no learning experience like encountering a problem, getting incredibly frustrated and then feeling elated when you find a solution. You will not come out of this course an expert in CSS.
Recommended sites: Why Tables for Layout is Stupid: http:// www.hotdesign.com/seybold / A List Apart: Practical CSS Layout Tips, Ticks & techniques: http:// www.alistapart.com/articles/practicalcss / Max Design Floatutorial: http:// css.maxdesign.com.au/floatutorial / Further reading: Web Design in a Nutshell,  3rd Edition  by Jennifer Niederst Robbins
 

More Related Content

Viewers also liked (6)

PDF
Node.js and How JavaScript is Changing Server Programming
Tom Croucher
 
PPTX
CSS corso base (classi seconde, mod 1)
Matteo Ziviani
 
PPT
Introduzione ai css
gianlucatroiani
 
PPTX
Intro To Node.js
Chris Cowan
 
PDF
Building servers with Node.js
ConFoo
 
PDF
Modern UI Development With Node.js
Ryan Anklam
 
Node.js and How JavaScript is Changing Server Programming
Tom Croucher
 
CSS corso base (classi seconde, mod 1)
Matteo Ziviani
 
Introduzione ai css
gianlucatroiani
 
Intro To Node.js
Chris Cowan
 
Building servers with Node.js
ConFoo
 
Modern UI Development With Node.js
Ryan Anklam
 

Similar to Lecture2 CSS 3 (20)

PPTX
Castro Chapter 11
Jeff Byrnes
 
PPT
Css advanced – session 4
Dr. Ramkumar Lakshminarayanan
 
PPTX
CSS_Day_Three (W3schools)
Rafi Haidari
 
PPTX
CSS_Dibbo
Sayanton Vhaduri
 
PPTX
Page layout with css
Er. Nawaraj Bhandari
 
PDF
ClaFundamentalsof Web Developmentss12 .pdf
kasperkey106
 
PPTX
Chapter 15: Floating and Positioning
Steve Guinan
 
PPTX
Advanced CSS.pptx
DiyonaVas
 
PPTX
Chapter05-Presentation.pptx
ssuserf3db48
 
PPTX
HTML5- Create divisions in a web page
Grayzon Gonzales, LPT
 
PPT
Web Designing Bugs - Fixes By Nyros Developer
Nyros Technologies
 
PDF
The Future of CSS Layout
Zoe Gillenwater
 
PPTX
css3.pptx
ThiyaguPappu
 
KEY
Style With Kyle - Kyle Smith
wcfay
 
PPTX
CSC PPT 9.pptx
DrRavneetSingh
 
PPT
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
PDF
Shaping Up With CSS
sdireland
 
PDF
Web Layout
Shawn Calvert
 
PDF
Web Design & Development - Session 3
Shahrzad Peyman
 
PPTX
Css 101
Rhyan Mahazudin
 
Castro Chapter 11
Jeff Byrnes
 
Css advanced – session 4
Dr. Ramkumar Lakshminarayanan
 
CSS_Day_Three (W3schools)
Rafi Haidari
 
CSS_Dibbo
Sayanton Vhaduri
 
Page layout with css
Er. Nawaraj Bhandari
 
ClaFundamentalsof Web Developmentss12 .pdf
kasperkey106
 
Chapter 15: Floating and Positioning
Steve Guinan
 
Advanced CSS.pptx
DiyonaVas
 
Chapter05-Presentation.pptx
ssuserf3db48
 
HTML5- Create divisions in a web page
Grayzon Gonzales, LPT
 
Web Designing Bugs - Fixes By Nyros Developer
Nyros Technologies
 
The Future of CSS Layout
Zoe Gillenwater
 
css3.pptx
ThiyaguPappu
 
Style With Kyle - Kyle Smith
wcfay
 
CSC PPT 9.pptx
DrRavneetSingh
 
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
Shaping Up With CSS
sdireland
 
Web Layout
Shawn Calvert
 
Web Design & Development - Session 3
Shahrzad Peyman
 
Ad

More from Sur College of Applied Sciences (15)

PPT
Lecture11 A Image
Sur College of Applied Sciences
 
PPT
Lecture 11 B Security
Sur College of Applied Sciences
 
PPT
Lecture 10 Image Format
Sur College of Applied Sciences
 
PPT
Lecture 9 Usability Orignal
Sur College of Applied Sciences
 
PPT
Lecture 9 Professional Practices
Sur College of Applied Sciences
 
PPT
Lecture 9 Accessibility Original
Sur College of Applied Sciences
 
PPT
Accessibility Usability Professional Summry
Sur College of Applied Sciences
 
PPT
Lecture 6 Data Driven Design
Sur College of Applied Sciences
 
PPT
Lecture1 B Frames&Forms
Sur College of Applied Sciences
 
PPT
Lecture 3 Javascript1
Sur College of Applied Sciences
 
Lecture 11 B Security
Sur College of Applied Sciences
 
Lecture 10 Image Format
Sur College of Applied Sciences
 
Lecture 9 Usability Orignal
Sur College of Applied Sciences
 
Lecture 9 Professional Practices
Sur College of Applied Sciences
 
Lecture 9 Accessibility Original
Sur College of Applied Sciences
 
Accessibility Usability Professional Summry
Sur College of Applied Sciences
 
Lecture 6 Data Driven Design
Sur College of Applied Sciences
 
Lecture1 B Frames&Forms
Sur College of Applied Sciences
 
Lecture 3 Javascript1
Sur College of Applied Sciences
 
Ad

Recently uploaded (20)

PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
Quarter 1_PPT_PE & HEALTH 8_WEEK 3-4.pptx
ronajadolpnhs
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPTX
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PPTX
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Quarter 1_PPT_PE & HEALTH 8_WEEK 3-4.pptx
ronajadolpnhs
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
Controller Request and Response in Odoo18
Celine George
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 

Lecture2 CSS 3

  • 1. Lecture 2 : CSS III SFDV2001 Web Development
  • 2. Page layout with CSS Tables, though still heavily used by web designers to control page layout, were never intended for that purpose. Ideally tables should be used for data only. As browsers become better at supporting web standards and as users of the web adopt those browsers, layout controlled entirely by CSS is becoming an increasingly realistic option. Even when table layout is still necessary, CSS streamlines their use, and makes your code much cleaner.
  • 3. Standard document flow When no layout control is implemented for an HTML page, elements flow from top to bottom, left to right: Block-level elements produce a line break that sees subsequent block-level elements come beneath them. Inline elements come one after the other, left to right, in the order they appear. The order sequence is determined by the tag sequence in your HTML. When you expand or contract the browser window, block-level elements alter to fit the new width.
  • 4. Standard document flow When you position elements with CSS you can remove an element from the normal flow. Order your HTML sensibly so that someone accessing it without style information can make sense of it: Title Navigation Main content Footer That order won’t affect what you can achieve with CSS with regard to layout.
  • 5. Float In Transitional HTML we could align an image to the right and have text wrap around it on the left using the align attribute. In CSS such behaviour is not limited to images. You can float any element. ul#nav{ float: left; }
  • 6. Clear Just as we had the clear attribute of <br> in transitional HTML to stop text from sitting beside an aligned image when we didn’t want it to, so we have clear to accompany float in CSS. The clear attribute of <br> had the possible values: left , right or all . In CSS clear gets: left , right , both , none or inherit . The clear property can only be applied to block-level elements.
  • 7. Position There are a number of different values of position in CSS: Static Relative Absolute Fixed Static is the normal (default) position of elements on your page. Elements conform to the standard document flow. Position (and any of its values) can apply to any element.
  • 8. Position Once you have determined what kind of positioning an element will employ (relative, absolute or fixed), the actual positioning is done via four properties: Top Right Bottom Left The values of these properties can be a length or a percentage. Top position refers to an elements distance from the top (the top of what depends on what kind of positioning you are employing).
  • 9. position: relative; Relative positioning moves an element from its place in the standard document flow but retains the space where it came from: position: relative; top: 40px; left: 40px; 40 40
  • 10. position: absolute; Absolute positioning moves an element from its place in the standard document flow and closes the space where it came from. An element is positioned absolutely with relation to its nearest parent element that isn’t statically positioned. position: absolute; top: 40px; left: 40px; 40 40
  • 11. position: fixed; Like absolute positioning, fixed positioning removes an element from the standard document flow, but instead of being fixed relative to its parent element it is fixed in relation to the view-port (normally the browser window). Can be useful to recreate frame like behaviour where a navigation menu can stay fixed while the rest of the content scrolls. Not as well supported as relative and absolute positioning.
  • 12. Position Combinations Relative and absolutely positioned elements in particular can be combined to give your layout greater flexibility. An absolutely positioned element inside a relative element is positioned absolutely with respect to that relatively positioned parent. So the parent may be flexible but the child always stays in the same place in relation to it. Time for an example I think.
  • 13. CSS and tables Please don’t get the message “tables are evil”. Tables should absolutely be used for tabular data:
  • 14. CSS and tables And they are still necessary for some layout purposes. Complex forms are still easier to control with a table than CSS (and in many instances the form information fits the tabular data description). When you have to use a table for layout control keep it as clean as possible; use your CSS to style it. Things like empty cells, though there were never very many good excuses for them, should be rare with CSS. Combining CSS and tables for layout can be more of a headache than using CSS alone, so don’t think you’re taking the easy route.
  • 15. Learn by example And by practice. Lots and lots of practice. You could sit in a thousand lectures, read a thousand articles and still not really “get” CSS. You absolutely must practice it: work out how things do what they do through experiment. There is no learning experience like encountering a problem, getting incredibly frustrated and then feeling elated when you find a solution. You will not come out of this course an expert in CSS.
  • 16. Recommended sites: Why Tables for Layout is Stupid: http:// www.hotdesign.com/seybold / A List Apart: Practical CSS Layout Tips, Ticks & techniques: http:// www.alistapart.com/articles/practicalcss / Max Design Floatutorial: http:// css.maxdesign.com.au/floatutorial / Further reading: Web Design in a Nutshell, 3rd Edition by Jennifer Niederst Robbins
  • 17.  

Editor's Notes

  • #3: Show google.comcode before and after (in Google directory). Show: Why tables for layout is stupid: http://www.hotdesign.com/seybold/
  • #5: Show 112 index.html without style sheet.
  • #6: Show lab three example Show examples: Nofloat.html - normal flow of document Basicfloat.html - nav ul floated and a border added so area can be seen. Float.html - bells and whistles.
  • #7: Show float.html again and discuss use of clear for footer.
  • #10: Show Position&gt; relative.html
  • #11: Show Position&gt; absolute.html
  • #12: Show fixed.html and Women in CS site.
  • #13: Show fixed.html and Women in CS site (http://www.cs.otago.ac.nz/staffpriv/morag/femmeweb/).
  • #16: Show sites with layout examples.