SlideShare a Scribd company logo
CSS: Box Model


 Author: Dwight VanTuyl
 Created: March 09, 2009
   The LINGUIST List
Box Model: Diagram
Padding
• Distance between the content and the
  border.
• Syntax:
  padding: top right bottom left
• Examples:
  padding: 0 5px 0 10px;
  padding: 0 0 0 0;
Border
• Line between padding and margin around
  content.
• Syntax:
  border: width style color
• Examples:
 border: thin solid red
 border-right: 10px double #FF2032
Margin
• Distance between the border and other
  elements.
• Transparent background
• Possible negative values
• Syntax:
  margin: top right bottom left
• Examples:
  margin: 0 -50px 0 10px;
  margin: 0 0 0 0;
Example
Example HTML
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
 <title>BoxModel Example01</title>
 <link rel="stylesheet" type="text/css" href="example01.css" />
</head>
<body>
  <div class="box" style="background-color:red;">BOX 01</div>
  <div class="box" style="background-color:blue;">BOX 02</div>
  <br style="clear:both;"/>
  <div class="box" style="background-color:green;">BOX 03</div>
  <div class="box" style="background-color:yellow;">BOX 04</div>
</body>
</html>
Example CSS
.box{
  float: left;
  height: 100px;
  width: 100px;
  padding: 20px 100px 0 50px;
  border: thick double black;
  margin: 0 30px 20% 2em;
  font-size: 2em;
  font-weight: bold;
  text-align: center;
}

More Related Content

PDF
Wikidata at Wikipeda Day 15 (2016) NYC
PDF
[Basic HTML/CSS] 6. css - box sizing, display, margin, padding
PPTX
Services and Anemic Domain
PPT
NISO Bibliographic Roadmap Meeting Proposal
PDF
You have been MOOCed
PPTX
CSS Box Model Presentation. Concept of DIV
PPTX
CSS: Box Model
PPSX
CSS Box Model Presentation
Wikidata at Wikipeda Day 15 (2016) NYC
[Basic HTML/CSS] 6. css - box sizing, display, margin, padding
Services and Anemic Domain
NISO Bibliographic Roadmap Meeting Proposal
You have been MOOCed
CSS Box Model Presentation. Concept of DIV
CSS: Box Model
CSS Box Model Presentation

Similar to CSS-Tutorial-boxmodel (20)

PPTX
Working with the CSS Box Model, syntaxxx
PPTX
Css box model
PPT
Box Model
PDF
Lab#7 CSS Box Model
PDF
11--CSS-Box-Model.pdf for second college
PPTX
presentation of advance web programming.pptx
PDF
Layout with CSS
PPTX
How to Create flex box and design box model for a particular section
PPTX
CSS BOX MODEL
PDF
PPTX
1 07-the box-model
PPTX
1-07: The Box Model
PPTX
Cascading style sheets (CSS-Web Technology)
PDF
GDI Seattle Intro to HTML and CSS - Class 3
PPTX
cascading style sheets explaining about borders
PDF
Css box model
PDF
CSS Boc model
PPTX
Css summary
PPTX
PPTX
Css box-model
Working with the CSS Box Model, syntaxxx
Css box model
Box Model
Lab#7 CSS Box Model
11--CSS-Box-Model.pdf for second college
presentation of advance web programming.pptx
Layout with CSS
How to Create flex box and design box model for a particular section
CSS BOX MODEL
1 07-the box-model
1-07: The Box Model
Cascading style sheets (CSS-Web Technology)
GDI Seattle Intro to HTML and CSS - Class 3
cascading style sheets explaining about borders
Css box model
CSS Boc model
Css summary
Css box-model
Ad

More from tutorialsruby (20)

PDF
&lt;img src="../i/r_14.png" />
PDF
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
PDF
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
PDF
&lt;img src="../i/r_14.png" />
PDF
&lt;img src="../i/r_14.png" />
PDF
Standardization and Knowledge Transfer – INS0
PDF
xhtml_basics
PDF
xhtml_basics
PDF
xhtml-documentation
PDF
xhtml-documentation
PDF
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
PDF
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
PDF
HowTo_CSS
PDF
HowTo_CSS
PDF
BloggingWithStyle_2008
PDF
BloggingWithStyle_2008
PDF
cascadingstylesheets
PDF
cascadingstylesheets
&lt;img src="../i/r_14.png" />
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
Standardization and Knowledge Transfer – INS0
xhtml_basics
xhtml_basics
xhtml-documentation
xhtml-documentation
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
HowTo_CSS
HowTo_CSS
BloggingWithStyle_2008
BloggingWithStyle_2008
cascadingstylesheets
cascadingstylesheets
Ad

Recently uploaded (20)

PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
cuic standard and advanced reporting.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Machine Learning_overview_presentation.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
A Presentation on Artificial Intelligence
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Electronic commerce courselecture one. Pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
A comparative analysis of optical character recognition models for extracting...
cuic standard and advanced reporting.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
20250228 LYD VKU AI Blended-Learning.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Unlocking AI with Model Context Protocol (MCP)
gpt5_lecture_notes_comprehensive_20250812015547.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Encapsulation_ Review paper, used for researhc scholars
Empathic Computing: Creating Shared Understanding
Machine Learning_overview_presentation.pptx
Spectral efficient network and resource selection model in 5G networks
Programs and apps: productivity, graphics, security and other tools
MYSQL Presentation for SQL database connectivity
A Presentation on Artificial Intelligence
Assigned Numbers - 2025 - Bluetooth® Document
Advanced methodologies resolving dimensionality complications for autism neur...
Electronic commerce courselecture one. Pdf

CSS-Tutorial-boxmodel

  • 1. CSS: Box Model Author: Dwight VanTuyl Created: March 09, 2009 The LINGUIST List
  • 3. Padding • Distance between the content and the border. • Syntax: padding: top right bottom left • Examples: padding: 0 5px 0 10px; padding: 0 0 0 0;
  • 4. Border • Line between padding and margin around content. • Syntax: border: width style color • Examples: border: thin solid red border-right: 10px double #FF2032
  • 5. Margin • Distance between the border and other elements. • Transparent background • Possible negative values • Syntax: margin: top right bottom left • Examples: margin: 0 -50px 0 10px; margin: 0 0 0 0;
  • 7. Example HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>BoxModel Example01</title> <link rel="stylesheet" type="text/css" href="example01.css" /> </head> <body> <div class="box" style="background-color:red;">BOX 01</div> <div class="box" style="background-color:blue;">BOX 02</div> <br style="clear:both;"/> <div class="box" style="background-color:green;">BOX 03</div> <div class="box" style="background-color:yellow;">BOX 04</div> </body> </html>
  • 8. Example CSS .box{ float: left; height: 100px; width: 100px; padding: 20px 100px 0 50px; border: thick double black; margin: 0 30px 20% 2em; font-size: 2em; font-weight: bold; text-align: center; }