SlideShare a Scribd company logo
Box Model
CSS 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;
CSS Box Model
CSS Box Model
 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
CSS Box Model
 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
CSS Box Model
 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
CSS Box Model
CSS Box Model
CSS Box Model
 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

PPTX
Css borders
PPTX
Pres
PDF
Ppt ch06
PPTX
Draw lines from shapes
PPT
CSS
PPTX
Web Engineering - Basic CSS Properties
PPTX
Web Development - Lecture 6
PPTX
CSS Topic wise Short notes ppt by Navya.E
Css borders
Pres
Ppt ch06
Draw lines from shapes
CSS
Web Engineering - Basic CSS Properties
Web Development - Lecture 6
CSS Topic wise Short notes ppt by Navya.E

Similar to CSS Box Model (20)

PDF
PDF
HTML ,CSS ,JQuery Cheat Sheet
PPTX
Lecture 6.pptx..........................
PPTX
Chapter 14: Box Model
PPTX
Introduction to CSS and all properties.pptx
PPTX
Cascading style sheets (CSS-Web Technology)
PPTX
cascading style sheets explaining about borders
PPTX
CSS Cascade Style Sheet
PPTX
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
PPTX
CSS tutorial chapter 2
PDF
CSS3 Refresher
PPTX
CSS3 basics for beginners - Imrokraft
PPT
CSS Basics
PPTX
Unit - 3 CSS(Cascading Style Sheet).pptx
PDF
Web Design Course: CSS lecture 3
PPTX
Css3 Complete Reference
HTML ,CSS ,JQuery Cheat Sheet
Lecture 6.pptx..........................
Chapter 14: Box Model
Introduction to CSS and all properties.pptx
Cascading style sheets (CSS-Web Technology)
cascading style sheets explaining about borders
CSS Cascade Style Sheet
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
CSS tutorial chapter 2
CSS3 Refresher
CSS3 basics for beginners - Imrokraft
CSS Basics
Unit - 3 CSS(Cascading Style Sheet).pptx
Web Design Course: CSS lecture 3
Css3 Complete Reference
Ad

More from kjkleindorfer (10)

PPTX
Logic and Coding of Java Interfaces & Swing Applications
PPTX
Week11 Inheritance class relationships in Java
PPTX
Week10 packages using objects in objects
PPTX
Week9 Intro to classes and objects in Java
PPTX
Intro to Bootstrap
PPTX
Layouts Part 2
PPTX
Layouts
PPTX
Using PHP to submit forms
PPTX
Forms Part 1
PPTX
CSS Selectors and Fonts
Logic and Coding of Java Interfaces & Swing Applications
Week11 Inheritance class relationships in Java
Week10 packages using objects in objects
Week9 Intro to classes and objects in Java
Intro to Bootstrap
Layouts Part 2
Layouts
Using PHP to submit forms
Forms Part 1
CSS Selectors and Fonts
Ad

Recently uploaded (20)

PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Institutional Correction lecture only . . .
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Complications of Minimal Access Surgery at WLH
PPTX
master seminar digital applications in india
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Pharma ospi slides which help in ospi learning
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Cell Structure & Organelles in detailed.
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Sports Quiz easy sports quiz sports quiz
PDF
Computing-Curriculum for Schools in Ghana
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
Microbial diseases, their pathogenesis and prophylaxis
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
O7-L3 Supply Chain Operations - ICLT Program
Institutional Correction lecture only . . .
TR - Agricultural Crops Production NC III.pdf
Complications of Minimal Access Surgery at WLH
master seminar digital applications in india
Final Presentation General Medicine 03-08-2024.pptx
Pharma ospi slides which help in ospi learning
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Abdominal Access Techniques with Prof. Dr. R K Mishra
Cell Structure & Organelles in detailed.
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Sports Quiz easy sports quiz sports quiz
Computing-Curriculum for Schools in Ghana
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Module 4: Burden of Disease Tutorial Slides S2 2025
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
O5-L3 Freight Transport Ops (International) V1.pdf

CSS Box Model

  • 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;
  • 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
  • 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
  • 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
  • 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)