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
 
Ad

More Related Content

Viewers also liked (6)

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

Similar to Lecture2 CSS 3 (20)

Page layout with css
Page layout with cssPage layout with css
Page layout with css
Er. Nawaraj Bhandari
 
Web Programming Basic topic.pptx
Web Programming Basic topic.pptxWeb Programming Basic topic.pptx
Web Programming Basic topic.pptx
ShouravPodder3
 
Css jon duckett - flashcards
Css   jon duckett - flashcardsCss   jon duckett - flashcards
Css jon duckett - flashcards
Chirag Aggarwal
 
Lecture 5 & 6 Advance CSS.pptx for web
Lecture 5 & 6 Advance  CSS.pptx for  webLecture 5 & 6 Advance  CSS.pptx for  web
Lecture 5 & 6 Advance CSS.pptx for web
ZahraWaheed9
 
CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)
Rafi Haidari
 
Advanced CSS.pptx
Advanced CSS.pptxAdvanced CSS.pptx
Advanced CSS.pptx
DiyonaVas
 
CSS3 PPT.pptx
CSS3 PPT.pptxCSS3 PPT.pptx
CSS3 PPT.pptx
AchieversIT
 
Css training
Css trainingCss training
Css training
Leigh Aucoin
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
Eliran Eliassy
 
Srijan presentation on CSS
Srijan presentation on CSSSrijan presentation on CSS
Srijan presentation on CSS
Shashank Merothiya
 
Floating
FloatingFloating
Floating
Danielle Larson
 
Floating power point
Floating power pointFloating power point
Floating power point
Danielle Larson
 
Lesson 3 - HTML & CSS Part 2
Lesson 3 - HTML & CSS Part 2Lesson 3 - HTML & CSS Part 2
Lesson 3 - HTML & CSS Part 2
hstryk
 
Css
CssCss
Css
NIRMAL FELIX
 
Floats
FloatsFloats
Floats
Diana Gabriela Cornelio
 
Web Development 4
Web Development 4Web Development 4
Web Development 4
ghayour abbas
 
Web Development 4 (HTML & CSS)
Web Development 4 (HTML & CSS)Web Development 4 (HTML & CSS)
Web Development 4 (HTML & CSS)
ghayour abbas
 
Margin vs Padding.pdf
Margin vs Padding.pdfMargin vs Padding.pdf
Margin vs Padding.pdf
WebMaxy
 
Organize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS TricksOrganize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS Tricks
Andolasoft Inc
 
Design and CSS
Design and CSSDesign and CSS
Design and CSS
nolly00
 
Web Programming Basic topic.pptx
Web Programming Basic topic.pptxWeb Programming Basic topic.pptx
Web Programming Basic topic.pptx
ShouravPodder3
 
Css jon duckett - flashcards
Css   jon duckett - flashcardsCss   jon duckett - flashcards
Css jon duckett - flashcards
Chirag Aggarwal
 
Lecture 5 & 6 Advance CSS.pptx for web
Lecture 5 & 6 Advance  CSS.pptx for  webLecture 5 & 6 Advance  CSS.pptx for  web
Lecture 5 & 6 Advance CSS.pptx for web
ZahraWaheed9
 
CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)CSS_Day_Three (W3schools)
CSS_Day_Three (W3schools)
Rafi Haidari
 
Advanced CSS.pptx
Advanced CSS.pptxAdvanced CSS.pptx
Advanced CSS.pptx
DiyonaVas
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
Eliran Eliassy
 
Lesson 3 - HTML & CSS Part 2
Lesson 3 - HTML & CSS Part 2Lesson 3 - HTML & CSS Part 2
Lesson 3 - HTML & CSS Part 2
hstryk
 
Web Development 4 (HTML & CSS)
Web Development 4 (HTML & CSS)Web Development 4 (HTML & CSS)
Web Development 4 (HTML & CSS)
ghayour abbas
 
Margin vs Padding.pdf
Margin vs Padding.pdfMargin vs Padding.pdf
Margin vs Padding.pdf
WebMaxy
 
Organize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS TricksOrganize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS Tricks
Andolasoft Inc
 
Design and CSS
Design and CSSDesign and CSS
Design and CSS
nolly00
 
Ad

More from Sur College of Applied Sciences (15)

Lecture11 A Image
Lecture11 A ImageLecture11 A Image
Lecture11 A Image
Sur College of Applied Sciences
 
Lecture 11 B Security
Lecture 11 B SecurityLecture 11 B Security
Lecture 11 B Security
Sur College of Applied Sciences
 
Lecture 10 Image Format
Lecture 10  Image FormatLecture 10  Image Format
Lecture 10 Image Format
Sur College of Applied Sciences
 
Lecture 9 Usability Orignal
Lecture 9 Usability OrignalLecture 9 Usability Orignal
Lecture 9 Usability Orignal
Sur College of Applied Sciences
 
Lecture 9 Professional Practices
Lecture 9 Professional PracticesLecture 9 Professional Practices
Lecture 9 Professional Practices
Sur College of Applied Sciences
 
Lecture 9 Accessibility Original
Lecture 9 Accessibility OriginalLecture 9 Accessibility Original
Lecture 9 Accessibility Original
Sur College of Applied Sciences
 
Accessibility Usability Professional Summry
Accessibility Usability Professional SummryAccessibility Usability Professional Summry
Accessibility Usability Professional Summry
Sur College of Applied Sciences
 
Lecture 8 Video
Lecture 8 VideoLecture 8 Video
Lecture 8 Video
Sur College of Applied Sciences
 
Lecture 6 Data Driven Design
Lecture 6  Data Driven DesignLecture 6  Data Driven Design
Lecture 6 Data Driven Design
Sur College of Applied Sciences
 
Lecture 5 XML
Lecture 5  XMLLecture 5  XML
Lecture 5 XML
Sur College of Applied Sciences
 
Lecture2 CSS 2
Lecture2  CSS 2Lecture2  CSS 2
Lecture2 CSS 2
Sur College of Applied Sciences
 
Lecture2 CSS1
Lecture2  CSS1Lecture2  CSS1
Lecture2 CSS1
Sur College of Applied Sciences
 
Lecture1 B Frames&Forms
Lecture1 B  Frames&FormsLecture1 B  Frames&Forms
Lecture1 B Frames&Forms
Sur College of Applied Sciences
 
Navigation1 A
Navigation1 ANavigation1 A
Navigation1 A
Sur College of Applied Sciences
 
Lecture 3 Javascript1
Lecture 3  Javascript1Lecture 3  Javascript1
Lecture 3 Javascript1
Sur College of Applied Sciences
 
Ad

Recently uploaded (20)

To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Library Association of Ireland
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
Unit 4: Long term- Capital budgeting and its types
Unit 4: Long term- Capital budgeting and its typesUnit 4: Long term- Capital budgeting and its types
Unit 4: Long term- Capital budgeting and its types
bharath321164
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-26-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 4-26-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 4-26-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-26-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Operations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdfOperations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdf
Arab Academy for Science, Technology and Maritime Transport
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Unit 5: Dividend Decisions and its theories
Unit 5: Dividend Decisions and its theoriesUnit 5: Dividend Decisions and its theories
Unit 5: Dividend Decisions and its theories
bharath321164
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
Vitamins Chapter-7, Biochemistry and clinical pathology, D.Pharm 2nd year
Vitamins Chapter-7, Biochemistry and clinical pathology, D.Pharm 2nd yearVitamins Chapter-7, Biochemistry and clinical pathology, D.Pharm 2nd year
Vitamins Chapter-7, Biochemistry and clinical pathology, D.Pharm 2nd year
ARUN KUMAR
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Library Association of Ireland
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
Unit 4: Long term- Capital budgeting and its types
Unit 4: Long term- Capital budgeting and its typesUnit 4: Long term- Capital budgeting and its types
Unit 4: Long term- Capital budgeting and its types
bharath321164
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Unit 5: Dividend Decisions and its theories
Unit 5: Dividend Decisions and its theoriesUnit 5: Dividend Decisions and its theories
Unit 5: Dividend Decisions and its theories
bharath321164
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
Vitamins Chapter-7, Biochemistry and clinical pathology, D.Pharm 2nd year
Vitamins Chapter-7, Biochemistry and clinical pathology, D.Pharm 2nd yearVitamins Chapter-7, Biochemistry and clinical pathology, D.Pharm 2nd year
Vitamins Chapter-7, Biochemistry and clinical pathology, D.Pharm 2nd year
ARUN KUMAR
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 

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.