SlideShare a Scribd company logo
1 of 31
Box Model
 The three most commonly used CSS box properties are:
 padding
 border
 margin
 The other two properties are:
 width
 length
 Padding is the internal white space that surrounds the contents of
an element.
 The padding properties control this internal white space.
 By default, the content of an element does not have padding.
 All major Web browsers add varying amounts of padding by
default.
 To set the padding within an element, use:
 padding: width;
 To set the padding for each side individually, the following four
properties can be used:
 padding-top
 padding-right
 padding-bottom
 padding-left
 The shorthand property can be used:
 padding: top right bottom left;
 Values for both the padding and the margin properties can be
expressed using:
 em (em values)
 px (pixels)
 mm (millimeters)
 cm (centimeters)
 in (inches)
 % (percentage of the container element)
 The margin properties control the external white space, which is
the white space outside the border.
 Every element has margins.
 The margin properties are often used to create a white space
around images.
 To set the margin space around an element, use:
 margin: width;
 To set the padding for each side individually, the following four
properties can be used:
 margin-top
 margin-right
 margin-bottom
 margin-left
 The shorthand property can be used:
 margin: top right bottom left;
 The border properties are used to place a decorative border
around the contents and padding of an element.
 The border is located between the padding and the margin.
 You can change a border’s:
 style
 color
 width
 The border-style value can be any one of the following:
– solid – double – dotted
– dashed – groove – ridge
– inset – outset – none (default)
 There are five border-style properties:
 border-top-style
 border-right-style
 border-bottom-style
 border-left-style
 border-style (shorthand property)
 Border thickness can be expressed using the keywords:
– thin
– medium
– thick
 There are five
border-width properties:
 border-top-width
 border-right-width
 border-bottom-width
 border-left-width
 border-width (shorthand property)
 The border color can be a named color, a hex value, or an RGB value.
 There are five border-color properties:
 border-top-color
 border-right-color
 border-bottom-color
 border-left-color
 border-color (shorthand property)
The following three properties change the border
style, width, or color for all four borders:
 border-color
 border-style
 border-width
The following four properties change the border
style, width, or color for an individual border:
 border-top
 border-right
 border-bottom
 border-left
To shorten the code, it is also possible to specify all
the individual border properties in one property.
The border property is a shorthand property for the
following individual border properties:
 border-width
 border-style (required)
 border-color
 Example
p {
border: 5px solid khaki;
}
h3 {
border-bottom: thick solid darkkhaki;
padding-bottom: 0.5em;
}
 The float property is used to position boxes on the page and to
wrap content, such as text, around a box.
 To float an element, use the style:
float: position;
 The position can have the following values:
 left
 right
 none
 The clear property is used to position the content of an element
below another element that has been floated.
 This is also called clearing past an element.
 To clear past an element, use the style:
clear: position;
 The position can have the following values:
 left
 right
 both
 The background properties set the background effects for an element.
 The following properties can be used:
- background-image - background-color
- background-position - background-repeat
- background-attachment - background
 For the last one, values must be listed in the following order:
image color position repeat attachment
 The background-image property is used to fill the background of an
element with an image.
 If this property is used with the body element as a selector, and if the
image is repeated both horizontally and vertically (the default), then
the background image will repeat to occupy the entire Web page.
 The background-position property allows you to position a
background image in different locations within its container element.
 The container element could be body, head, or footer.
 The background-repeat property can be used to have copies
of an image appear behind an element horizontally, vertically, or
both.
 Repeating an image is known as tiling.
 The background-attachment property allows you to set the
behavior of the background image with respect to scrolling.
 This property accepts two values:
 scroll (the default value) – image scrolls down the page
 fixed – image stays in place and the text scrolls over the image as
the user scrolls down the page
 The term cascading in CSS refers to the methods used to
determine which style rules apply if more than one rule styles the
same element.
 Style precedence determines which styles have priority.
 There are five possible sources for styles.
 The order of precedence (from highest precedence to lowest) is
as follows:
1. User-defined styles
2. Inline styles
3. Embedded style sheet styles
4. External style sheet styles
5. The browser’s style sheet (the browser’s default styles)

More Related Content

Similar to CSS Box Model

Similar to CSS Box Model (20)

Chapter 14: Box Model
Chapter 14: Box ModelChapter 14: Box Model
Chapter 14: Box Model
 
Cascading style sheet part 2
Cascading style sheet   part 2Cascading style sheet   part 2
Cascading style sheet part 2
 
CSS3: Background And DropShadows:
CSS3: Background And DropShadows:CSS3: Background And DropShadows:
CSS3: Background And DropShadows:
 
Css
CssCss
Css
 
css3.pptx
css3.pptxcss3.pptx
css3.pptx
 
CSS3 Backgrounds
CSS3 BackgroundsCSS3 Backgrounds
CSS3 Backgrounds
 
Art of css
Art of cssArt of css
Art of css
 
Introduction to CSS Borders - Lesson 4
Introduction to CSS Borders - Lesson 4Introduction to CSS Borders - Lesson 4
Introduction to CSS Borders - Lesson 4
 
Css outlines
Css outlinesCss outlines
Css outlines
 
Cascading style sheets (CSS-Web Technology)
Cascading style sheets (CSS-Web Technology)Cascading style sheets (CSS-Web Technology)
Cascading style sheets (CSS-Web Technology)
 
Border
BorderBorder
Border
 
Web Engineering - Basic CSS Properties
Web Engineering - Basic CSS PropertiesWeb Engineering - Basic CSS Properties
Web Engineering - Basic CSS Properties
 
CSS Cascade Style Sheet
CSS Cascade Style SheetCSS Cascade Style Sheet
CSS Cascade Style Sheet
 
basics of css
basics of cssbasics of css
basics of css
 
Dimensions of elements.pdf
Dimensions of elements.pdfDimensions of elements.pdf
Dimensions of elements.pdf
 
Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3
 
Chapter 4 Graphic Design with CSS
Chapter 4 Graphic Design with CSSChapter 4 Graphic Design with CSS
Chapter 4 Graphic Design with CSS
 
Css
CssCss
Css
 
9781305503922t4-200824144338 (2).pdf
9781305503922t4-200824144338 (2).pdf9781305503922t4-200824144338 (2).pdf
9781305503922t4-200824144338 (2).pdf
 
Css presentation lecture 4
Css presentation lecture 4Css presentation lecture 4
Css presentation lecture 4
 

More from kjkleindorfer

Logic and Coding of Java Interfaces & Swing Applications
Logic and Coding of Java Interfaces & Swing ApplicationsLogic and Coding of Java Interfaces & Swing Applications
Logic and Coding of Java Interfaces & Swing Applicationskjkleindorfer
 
Week11 Inheritance class relationships in Java
Week11 Inheritance class relationships in JavaWeek11 Inheritance class relationships in Java
Week11 Inheritance class relationships in Javakjkleindorfer
 
Week10 packages using objects in objects
Week10 packages using objects in objectsWeek10 packages using objects in objects
Week10 packages using objects in objectskjkleindorfer
 
Week9 Intro to classes and objects in Java
Week9 Intro to classes and objects in JavaWeek9 Intro to classes and objects in Java
Week9 Intro to classes and objects in Javakjkleindorfer
 
Using PHP to submit forms
Using PHP to submit formsUsing PHP to submit forms
Using PHP to submit formskjkleindorfer
 
CSS Selectors and Fonts
CSS Selectors and FontsCSS Selectors and Fonts
CSS Selectors and Fontskjkleindorfer
 

More from kjkleindorfer (10)

Logic and Coding of Java Interfaces & Swing Applications
Logic and Coding of Java Interfaces & Swing ApplicationsLogic and Coding of Java Interfaces & Swing Applications
Logic and Coding of Java Interfaces & Swing Applications
 
Week11 Inheritance class relationships in Java
Week11 Inheritance class relationships in JavaWeek11 Inheritance class relationships in Java
Week11 Inheritance class relationships in Java
 
Week10 packages using objects in objects
Week10 packages using objects in objectsWeek10 packages using objects in objects
Week10 packages using objects in objects
 
Week9 Intro to classes and objects in Java
Week9 Intro to classes and objects in JavaWeek9 Intro to classes and objects in Java
Week9 Intro to classes and objects in Java
 
Intro to Bootstrap
Intro to BootstrapIntro to Bootstrap
Intro to Bootstrap
 
Layouts Part 2
Layouts Part 2Layouts Part 2
Layouts Part 2
 
Layouts
Layouts Layouts
Layouts
 
Using PHP to submit forms
Using PHP to submit formsUsing PHP to submit forms
Using PHP to submit forms
 
Forms Part 1
Forms Part 1Forms Part 1
Forms Part 1
 
CSS Selectors and Fonts
CSS Selectors and FontsCSS Selectors and Fonts
CSS Selectors and Fonts
 

Recently uploaded

call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 

Recently uploaded (20)

Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 

CSS Box Model

  • 2.
  • 3.  The three most commonly used CSS box properties are:  padding  border  margin  The other two properties are:  width  length
  • 4.  Padding is the internal white space that surrounds the contents of an element.  The padding properties control this internal white space.  By default, the content of an element does not have padding.  All major Web browsers add varying amounts of padding by default.
  • 5.  To set the padding within an element, use:  padding: width;  To set the padding for each side individually, the following four properties can be used:  padding-top  padding-right  padding-bottom  padding-left  The shorthand property can be used:  padding: top right bottom left;
  • 6.  Values for both the padding and the margin properties can be expressed using:  em (em values)  px (pixels)  mm (millimeters)  cm (centimeters)  in (inches)  % (percentage of the container element)
  • 7.  The margin properties control the external white space, which is the white space outside the border.  Every element has margins.  The margin properties are often used to create a white space around images.
  • 8.  To set the margin space around an element, use:  margin: width;  To set the padding for each side individually, the following four properties can be used:  margin-top  margin-right  margin-bottom  margin-left  The shorthand property can be used:  margin: top right bottom left;
  • 9.
  • 10.
  • 11.  The border properties are used to place a decorative border around the contents and padding of an element.  The border is located between the padding and the margin.  You can change a border’s:  style  color  width
  • 12.  The border-style value can be any one of the following: – solid – double – dotted – dashed – groove – ridge – inset – outset – none (default)  There are five border-style properties:  border-top-style  border-right-style  border-bottom-style  border-left-style  border-style (shorthand property)
  • 13.  Border thickness can be expressed using the keywords: – thin – medium – thick  There are five border-width properties:  border-top-width  border-right-width  border-bottom-width  border-left-width  border-width (shorthand property)
  • 14.  The border color can be a named color, a hex value, or an RGB value.  There are five border-color properties:  border-top-color  border-right-color  border-bottom-color  border-left-color  border-color (shorthand property)
  • 15. The following three properties change the border style, width, or color for all four borders:  border-color  border-style  border-width The following four properties change the border style, width, or color for an individual border:  border-top  border-right  border-bottom  border-left
  • 16. To shorten the code, it is also possible to specify all the individual border properties in one property. The border property is a shorthand property for the following individual border properties:  border-width  border-style (required)  border-color  Example p { border: 5px solid khaki; }
  • 17. h3 { border-bottom: thick solid darkkhaki; padding-bottom: 0.5em; }
  • 18.  The float property is used to position boxes on the page and to wrap content, such as text, around a box.  To float an element, use the style: float: position;  The position can have the following values:  left  right  none
  • 19.
  • 20.  The clear property is used to position the content of an element below another element that has been floated.  This is also called clearing past an element.  To clear past an element, use the style: clear: position;  The position can have the following values:  left  right  both
  • 21.
  • 22.  The background properties set the background effects for an element.  The following properties can be used: - background-image - background-color - background-position - background-repeat - background-attachment - background  For the last one, values must be listed in the following order: image color position repeat attachment
  • 23.  The background-image property is used to fill the background of an element with an image.  If this property is used with the body element as a selector, and if the image is repeated both horizontally and vertically (the default), then the background image will repeat to occupy the entire Web page.
  • 24.  The background-position property allows you to position a background image in different locations within its container element.  The container element could be body, head, or footer.
  • 25.  The background-repeat property can be used to have copies of an image appear behind an element horizontally, vertically, or both.  Repeating an image is known as tiling.
  • 26.  The background-attachment property allows you to set the behavior of the background image with respect to scrolling.  This property accepts two values:  scroll (the default value) – image scrolls down the page  fixed – image stays in place and the text scrolls over the image as the user scrolls down the page
  • 27.
  • 28.
  • 29.
  • 30.  The term cascading in CSS refers to the methods used to determine which style rules apply if more than one rule styles the same element.  Style precedence determines which styles have priority.  There are five possible sources for styles.
  • 31.  The order of precedence (from highest precedence to lowest) is as follows: 1. User-defined styles 2. Inline styles 3. Embedded style sheet styles 4. External style sheet styles 5. The browser’s style sheet (the browser’s default styles)