SlideShare a Scribd company logo
1 of 18
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

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

SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 

Recently uploaded (20)

SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 

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