Working with the CSS
Box Model
What is the CSS Box Model?
•The box model is a fundamental concept in web
design.
•It defines how elements are structured and how
their dimensions are calculated.
Importance
 Helps control the layout and spacing of
elements on a webpage.
The Components of the Box Model
•Content: The actual content of the element (text,
images, etc.)
•Padding: Space between the content and the border.
•Border: Surrounds the padding (if present) and the
content.
•Margin: Outermost space around the element
(separates elements from each other).
Box Model Properties in CSS
 Width and Height: Defines the content area of the box.
 Padding: Can be set for each side (top, right, bottom,
left).
 Border: Can also be set for each side (top, right,
bottom, left).
 Margin: Sets the space between the box and other
elements.
Box-Sizing Property
•Default Behavior: The default box-sizing is content-box, meaning padding and border
are added to the width/height.
•Alternative Behavior: box-sizing: border-box; includes padding and border within the
element’s width/height, preventing overflow.
•When to use: Use border-box for simpler layouts and to avoid unexpected
overflow.
Working with Box Model in CSS
Example 1: Simple box with padding, border, and margin
.box {
width: 200px;
height: 100px;
padding: 20px;
border: 5px solid #000;
margin: 15px;
}

More Related Content

PPTX
CSS Box Model Presentation. Concept of DIV
PPSX
CSS Box Model Presentation
PPTX
CSS: Box Model
PDF
Lab#7 CSS Box Model
PPTX
Css box model
PPT
Box Model
PDF
CSS-Tutorial-boxmodel
PDF
CSS-Tutorial-boxmodel
CSS Box Model Presentation. Concept of DIV
CSS Box Model Presentation
CSS: Box Model
Lab#7 CSS Box Model
Css box model
Box Model
CSS-Tutorial-boxmodel
CSS-Tutorial-boxmodel

Similar to Working with the CSS Box Model, syntaxxx (20)

PPTX
presentation of advance web programming.pptx
PPTX
How to Create flex box and design box model for a particular section
PPTX
Cascading style sheets (CSS-Web Technology)
PPTX
Css box-model
PDF
11--CSS-Box-Model.pdf for second college
PPTX
Web programming css
PPTX
CSS BOX MODEL
PPTX
Lecture 6.pptx..........................
PDF
PPTX
CHAPTER 3_ Getting Started with CSS Module
PDF
Box Model and Page Layouts
PPTX
Chapter 14: Box Model
PDF
GDI Seattle Intro to HTML and CSS - Class 3
PPTX
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
PDF
Web Layout
PDF
Layout with CSS
PPTX
cascading style sheets explaining about borders
PPTX
CSS Box Model
PPTX
Css presentation lecture 4
PPT
Advance Css 1194323118268797 5
presentation of advance web programming.pptx
How to Create flex box and design box model for a particular section
Cascading style sheets (CSS-Web Technology)
Css box-model
11--CSS-Box-Model.pdf for second college
Web programming css
CSS BOX MODEL
Lecture 6.pptx..........................
CHAPTER 3_ Getting Started with CSS Module
Box Model and Page Layouts
Chapter 14: Box Model
GDI Seattle Intro to HTML and CSS - Class 3
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Web Layout
Layout with CSS
cascading style sheets explaining about borders
CSS Box Model
Css presentation lecture 4
Advance Css 1194323118268797 5
Ad

Recently uploaded (20)

PDF
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
PDF
English Textual Question & Ans (12th Class).pdf
PDF
HVAC Specification 2024 according to central public works department
PDF
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
PDF
IP : I ; Unit I : Preformulation Studies
PDF
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
PDF
LIFE & LIVING TRILOGY - PART (3) REALITY & MYSTERY.pdf
PDF
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
PPTX
Core Concepts of Personalized Learning and Virtual Learning Environments
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
DOCX
Cambridge-Practice-Tests-for-IELTS-12.docx
PDF
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
PPTX
DRUGS USED FOR HORMONAL DISORDER, SUPPLIMENTATION, CONTRACEPTION, & MEDICAL T...
PPTX
What’s under the hood: Parsing standardized learning content for AI
PDF
International_Financial_Reporting_Standa.pdf
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PDF
Journal of Dental Science - UDMY (2022).pdf
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
English Textual Question & Ans (12th Class).pdf
HVAC Specification 2024 according to central public works department
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
IP : I ; Unit I : Preformulation Studies
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
LIFE & LIVING TRILOGY - PART (3) REALITY & MYSTERY.pdf
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
Core Concepts of Personalized Learning and Virtual Learning Environments
FORM 1 BIOLOGY MIND MAPS and their schemes
Cambridge-Practice-Tests-for-IELTS-12.docx
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
DRUGS USED FOR HORMONAL DISORDER, SUPPLIMENTATION, CONTRACEPTION, & MEDICAL T...
What’s under the hood: Parsing standardized learning content for AI
International_Financial_Reporting_Standa.pdf
Unit 4 Computer Architecture Multicore Processor.pptx
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
AI-driven educational solutions for real-life interventions in the Philippine...
Journal of Dental Science - UDMY (2022).pdf
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
Ad

Working with the CSS Box Model, syntaxxx

  • 1. Working with the CSS Box Model
  • 2. What is the CSS Box Model? •The box model is a fundamental concept in web design. •It defines how elements are structured and how their dimensions are calculated.
  • 3. Importance  Helps control the layout and spacing of elements on a webpage.
  • 4. The Components of the Box Model •Content: The actual content of the element (text, images, etc.) •Padding: Space between the content and the border. •Border: Surrounds the padding (if present) and the content. •Margin: Outermost space around the element (separates elements from each other).
  • 5. Box Model Properties in CSS  Width and Height: Defines the content area of the box.  Padding: Can be set for each side (top, right, bottom, left).  Border: Can also be set for each side (top, right, bottom, left).  Margin: Sets the space between the box and other elements.
  • 6. Box-Sizing Property •Default Behavior: The default box-sizing is content-box, meaning padding and border are added to the width/height. •Alternative Behavior: box-sizing: border-box; includes padding and border within the element’s width/height, preventing overflow. •When to use: Use border-box for simpler layouts and to avoid unexpected overflow.
  • 7. Working with Box Model in CSS Example 1: Simple box with padding, border, and margin .box { width: 200px; height: 100px; padding: 20px; border: 5px solid #000; margin: 15px; }