SlideShare a Scribd company logo
DESIGN WEBSITES
USING HTML & CSS
CSS Layouts
Outline
 Overview fonts, sizing, licensing and
packaging for the web
 CSS layout and positioning basics
 Block and inline styles
 Margins, paddings
 Floating
 Absolute and Relative positioning
Setting font sizes
Unit Identifier Corresponding
Units
pt points
pc picas
px pixels
em ems
ex exes
% percentages
 Avoid using points
and picas: print
design
 Pixels: consistent
text displays, but
cannot be resized
 Ems: relative font
measurement (ie
0.9em or 1.1em)
 Percentages: honor
users’ text size
Sizing fonts using keywords
 Alternative to numerical – absolute and
relative keywords
 xx-small, x-small, small, medium, large, x-
large, xx-large
 Keywords are defined relative to each other
 Browsers implement them differently
 Absolute but text can be resized in browser (issue
is inconsistency
 Relative size keywords (larger, smaller) takes its
size from the parent element
Example
Relative css
p{ font-size: small; }
em{font-size: larger;}
Relative html
<p>Garlic may be
known for being a
little bit
<em>stinky</em>,
but baked it is
delicious.
What to chose?
 Always allow for resizing – this is a AA
Accessibility standard
 Use a combination of ems (to set the base
size) and percentages within the document
Fonts and users’ computers
 Be careful with selecting fonts, as only a few
fonts are on every users computers
 Fonts are often licensed so you may need to
purchase
 Google fonts are another alternative
 Library is extensive
 Free
 https://fonts.google.com/
 Can embed them into your website
CSS Positioning Basics
 Class or ID
 ID
 must be only used once in a document
 Uniquely identifies the element to which it applies
 Once assigned you cannot use that ID again
within that document
CSS Positioning Basics
 Class
 Used as many times as you like within a document
 If there are features on the document you would like
to repeat – use a class
CSS positioning
Block level and in-line elements
 Elements are categorised as block or in-line,
this affects the default way they behave in
browsers
 This default display method can be changed
using the display property
 See example where we can see some HTML
elements, each describing their default display
(block or inline) with an example of what
happens if we change the display property on
that element
Block-level and inline elements
Inline Elements
 Only take up the space that it needs
 Ignore top and bottom margins if applied
 Disregard height and width properties
 Can be affected by the vertical-align property
 An inline element will become block-level if
you set the display property to block, or if you
float the element.
 Floated elements automatically become block
level and so height, width and all margins take
effect
Block-level Elements
 Will force a line break
 Drop to the next line in your document
 Expand to fill the parent element unless a
width has been given
 Respect all margin and padding properties
 Expand in height to fit everything they contain
 A div will expand to contain any amount of text
and images as long as the text and images are
not positioned or floated
 Not affected by vertical-align
Inline-block Elements
 If you set an element to display: in-line-block it
will behave like a block level element and
respect all margins, padding height and width
Margins and padding
 Margins – add space to the outside of an
element
 Set margins individually ie.,
 margin-top: 1em;
 margin-right: 2em
 margin-bottom: 0.5em;
 margin-left: 3em;
 Or
 margin: 1em 2em 0.5em 3em;
 Or if equal
 margin: 1em
Example: add margin to p
element
Padding
 Adds space inside the elements between
borders and its content
 Like margins, padding can be set individually
for the top, right, bottom, and left sides of the
element
 Using shorthand: padding: 1em 1.5em 0.5em
2em;
 Or equal: padding: 1em
Padding example

More Related Content

Similar to Css layouts-continued

CSS INHERITANCE
CSS INHERITANCECSS INHERITANCE
CSS INHERITANCE
Anuradha
 
Getting started with css
Getting started with cssGetting started with css
Getting started with css
Shivani Thakur Daxini
 
Introduction to css - a complete guide towards css
Introduction to css - a complete guide towards cssIntroduction to css - a complete guide towards css
Introduction to css - a complete guide towards css
DailyReminder1
 
Web 2 | CSS - Cascading Style Sheets
Web 2 | CSS - Cascading Style SheetsWeb 2 | CSS - Cascading Style Sheets
Web 2 | CSS - Cascading Style Sheets
Mohammad Imam Hossain
 
Designing for the web - 101
Designing for the web - 101Designing for the web - 101
Designing for the web - 101
Ashraf Hamdy
 
Css basics
Css basicsCss basics
Css basics
mirza asif haider
 
Css Introduction
Css IntroductionCss Introduction
Css Introduction
SathyaseelanK1
 
CSS Notes in PDF, Easy to understand. For beginner to advanced. ...
CSS Notes in PDF, Easy to understand. For beginner to advanced.              ...CSS Notes in PDF, Easy to understand. For beginner to advanced.              ...
CSS Notes in PDF, Easy to understand. For beginner to advanced. ...
syedfaisal759877
 
Lecture-7.pptx
Lecture-7.pptxLecture-7.pptx
Lecture-7.pptx
vishal choudhary
 
Basic css
Basic cssBasic css
Basic css
Gopinath Ambothi
 
Css Complete Notes
Css Complete NotesCss Complete Notes
Css Complete Notes
EPAM Systems
 
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
 
Chapter 11: Intro to CSS
Chapter 11: Intro to CSSChapter 11: Intro to CSS
Chapter 11: Intro to CSS
Steve Guinan
 
Css
CssCss
Week5 ap forms
Week5 ap formsWeek5 ap forms
Week5 ap forms
Rowena LI
 
Css
CssCss
Css
CssCss
CSS Foundations, pt 2
CSS Foundations, pt 2CSS Foundations, pt 2
CSS Foundations, pt 2
Shawn Calvert
 
Margin vs Padding.pdf
Margin vs Padding.pdfMargin vs Padding.pdf
Margin vs Padding.pdf
WebMaxy
 
CSS
CSSCSS

Similar to Css layouts-continued (20)

CSS INHERITANCE
CSS INHERITANCECSS INHERITANCE
CSS INHERITANCE
 
Getting started with css
Getting started with cssGetting started with css
Getting started with css
 
Introduction to css - a complete guide towards css
Introduction to css - a complete guide towards cssIntroduction to css - a complete guide towards css
Introduction to css - a complete guide towards css
 
Web 2 | CSS - Cascading Style Sheets
Web 2 | CSS - Cascading Style SheetsWeb 2 | CSS - Cascading Style Sheets
Web 2 | CSS - Cascading Style Sheets
 
Designing for the web - 101
Designing for the web - 101Designing for the web - 101
Designing for the web - 101
 
Css basics
Css basicsCss basics
Css basics
 
Css Introduction
Css IntroductionCss Introduction
Css Introduction
 
CSS Notes in PDF, Easy to understand. For beginner to advanced. ...
CSS Notes in PDF, Easy to understand. For beginner to advanced.              ...CSS Notes in PDF, Easy to understand. For beginner to advanced.              ...
CSS Notes in PDF, Easy to understand. For beginner to advanced. ...
 
Lecture-7.pptx
Lecture-7.pptxLecture-7.pptx
Lecture-7.pptx
 
Basic css
Basic cssBasic css
Basic css
 
Css Complete Notes
Css Complete NotesCss Complete Notes
Css Complete Notes
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
 
Chapter 11: Intro to CSS
Chapter 11: Intro to CSSChapter 11: Intro to CSS
Chapter 11: Intro to CSS
 
Css
CssCss
Css
 
Week5 ap forms
Week5 ap formsWeek5 ap forms
Week5 ap forms
 
Css
CssCss
Css
 
Css
CssCss
Css
 
CSS Foundations, pt 2
CSS Foundations, pt 2CSS Foundations, pt 2
CSS Foundations, pt 2
 
Margin vs Padding.pdf
Margin vs Padding.pdfMargin vs Padding.pdf
Margin vs Padding.pdf
 
CSS
CSSCSS
CSS
 

Recently uploaded

The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 

Recently uploaded (20)

The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 

Css layouts-continued

  • 1. DESIGN WEBSITES USING HTML & CSS CSS Layouts
  • 2. Outline  Overview fonts, sizing, licensing and packaging for the web  CSS layout and positioning basics  Block and inline styles  Margins, paddings  Floating  Absolute and Relative positioning
  • 3. Setting font sizes Unit Identifier Corresponding Units pt points pc picas px pixels em ems ex exes % percentages  Avoid using points and picas: print design  Pixels: consistent text displays, but cannot be resized  Ems: relative font measurement (ie 0.9em or 1.1em)  Percentages: honor users’ text size
  • 4. Sizing fonts using keywords  Alternative to numerical – absolute and relative keywords  xx-small, x-small, small, medium, large, x- large, xx-large  Keywords are defined relative to each other  Browsers implement them differently  Absolute but text can be resized in browser (issue is inconsistency  Relative size keywords (larger, smaller) takes its size from the parent element
  • 5. Example Relative css p{ font-size: small; } em{font-size: larger;} Relative html <p>Garlic may be known for being a little bit <em>stinky</em>, but baked it is delicious.
  • 6. What to chose?  Always allow for resizing – this is a AA Accessibility standard  Use a combination of ems (to set the base size) and percentages within the document
  • 7. Fonts and users’ computers  Be careful with selecting fonts, as only a few fonts are on every users computers  Fonts are often licensed so you may need to purchase  Google fonts are another alternative  Library is extensive  Free  https://fonts.google.com/  Can embed them into your website
  • 8. CSS Positioning Basics  Class or ID  ID  must be only used once in a document  Uniquely identifies the element to which it applies  Once assigned you cannot use that ID again within that document
  • 9. CSS Positioning Basics  Class  Used as many times as you like within a document  If there are features on the document you would like to repeat – use a class
  • 10. CSS positioning Block level and in-line elements  Elements are categorised as block or in-line, this affects the default way they behave in browsers  This default display method can be changed using the display property  See example where we can see some HTML elements, each describing their default display (block or inline) with an example of what happens if we change the display property on that element
  • 12. Inline Elements  Only take up the space that it needs  Ignore top and bottom margins if applied  Disregard height and width properties  Can be affected by the vertical-align property  An inline element will become block-level if you set the display property to block, or if you float the element.  Floated elements automatically become block level and so height, width and all margins take effect
  • 13. Block-level Elements  Will force a line break  Drop to the next line in your document  Expand to fill the parent element unless a width has been given  Respect all margin and padding properties  Expand in height to fit everything they contain  A div will expand to contain any amount of text and images as long as the text and images are not positioned or floated  Not affected by vertical-align
  • 14. Inline-block Elements  If you set an element to display: in-line-block it will behave like a block level element and respect all margins, padding height and width
  • 15. Margins and padding  Margins – add space to the outside of an element  Set margins individually ie.,  margin-top: 1em;  margin-right: 2em  margin-bottom: 0.5em;  margin-left: 3em;  Or  margin: 1em 2em 0.5em 3em;  Or if equal  margin: 1em
  • 16. Example: add margin to p element
  • 17. Padding  Adds space inside the elements between borders and its content  Like margins, padding can be set individually for the top, right, bottom, and left sides of the element  Using shorthand: padding: 1em 1.5em 0.5em 2em;  Or equal: padding: 1em

Editor's Notes

  1. Ems come from the typographical world where it relates to the letter M – usually the widest character in a font. In CSS, 1 em is seen to be equal to the user’s default font size. To display text at a size 10% smaller than the user’s default you can use this rule. % - 100% users default decreasing smaller