SlideShare a Scribd company logo
CSS BOXES &
DIMENSIONS
Advanced CSS techniques
the box model
• All HTML elements are rendered as
  boxes
• Stylesheets can control how to display
  these boxes (color, placement, etc)
• There arepaddingproperties of boxes:
  border,
            3 basic
                    and margin
CSS Box Model and Dimensions
BORDERS
border-width:3px;
border-style:dashed;
border-color:green;


border-left-width:thick;
border-bottom-style:solid;
border-right-color:blue;
MARGINS
margin:5px;

margin-top:30%;
margin-bottom:-50px;

margin-left:auto;
margin-right:auto;
PADDING
padding:5px;

padding-top:10%;
padding-bottom:2em;

padding-left:30px;
padding-right:2.5em;
box model shortcuts
•   padding:5px; all sides 5px

•   margin:5px 2px;
    top & bottom=5px, left & right 2px
•   border:1px 2px 3px;
    top=1px, left & right=2px, bottom=3px
•   padding:7px 3px 1px 6px;
    (clockwise from top)
DIMENSIONS

• The size of the box can be changed
  using these properties:
 •   width:80%

 •   height:300px
Add all the
values to get
the actual
dimensions of
the box
SPEED TEST 01
	   <div id="cool">
	   <p>this box is cool</p>
	   </div>
	   <div id="hot">
	   <p>this box is hot</p>
	   </div>
speed test 01
speed test 01
	   	   #cool {
	   	   background-color:blue;
	   	   width:500px;
	   	   height:200px;
	   	   }
	   	   #hot {
	   	   background-color:red;
	   	   width:200px;
	   	   height:200px;
	   	   }
speed test 02
speed test 02
	   	   #cool {
	   	   background-color:blue;
	   	   width:500px;
	   	   height:200px;
	   	   padding:10px;
	   	   }
	   	   #cool p {
	   	   border:5px solid white;
	   	   padding:10px;
	   	   }
SPEED TEST 03
speed test 03
	   	   #hot {
	   	   background-color:red;
	   	   width:200px;
	   	   height:200px;
	   	   border-width:10px;
	   	   border-style:dotted dashed;
	   	   margin-left:520px;
	   	   margin-top:-220px;
	   	   }
speed test 04
speed test 04
	   	   #hot p {
	   	   width:100px;
	   	   border:3px solid yellow;
	   	   margin-left:auto;
	   	   margin-right:auto;
	   	   font-size:30px;
	   	   padding:5px;
	   	   }
types of boxes
• HTML boxes can be categorized into
    two types:
    1. Block
    2. Inline
•   They can be controlled by the CSS
    property display
BLOCK BOX
• Occupies the whole
  width of the
  container element
• Has whitespace
  before and after it
• Dimensions are          <p> <h1> to <h6>
                        <div> <ul> <ol> <li>
  controllable
inline box
• Only as wide as
  its content
• Flows with text
  lines
• Dimensions
  aren’t easily
  controllable            <a> <span>
                     <strong> <em> <img>
inline vs block
speed test 05
<ul>
<li><a href="#">Sisig</a></li>	
<li><a href="#">Sinigang</a></li>	
<li><a href="#">Tapsilog</a></li>	
<li><a href="#">Kaldereta</a></li>	
<li><a href="#">Adobo</a></li>	
<li><a href="#">Bistek</a></li>	
<li><a href="#">Mechado</a></li>	
<li><a href="#">Laing</a></li>
</ul>
<a href="#">Back to Home</a>
Speed Test 05
speed test 05
	   	
    ul#navi {
	   	
    font-family:Rockwell;
	   	
    list-style:none;
	   	
    margin:0;
	   	
    padding:0;
	   	
    }
    ul#navi li a{
	 	 text-decoration:none;
	 	 }
Speed Test 06
speed test 06
        ul#navi li a{
	   	   text-decoration:none;
	   	   border-left:5px solid red;
	   	   border-right:5px solid red;
	   	   padding:5px;
        }
        ul#navi li a:link,
        ul#navi li a:visited {
	 	     color:black;
        }
Speed Test 07
speed test 07
	   	   ul#navi {
	   	   width:100px;
	   	   }
	   	   ul#navi li a{
	   	   display:block;
	   	   margin-top:5px;
	   	   text-align:center;
	   	   }
Speed Test 08

•   Change the background color and the
    borders when you hover
•   Change the background color and the
    borders when you click

More Related Content

PDF
Css box model
PDF
Lab#7 CSS Box Model
PPSX
CSS Box Model Presentation
PDF
CSS Box Model
PPT
5.1 css box model
PPTX
The Box Model [CSS Introduction]
PPTX
Css box-model
PPT
CSS, CSS Selectors, CSS Box Model
Css box model
Lab#7 CSS Box Model
CSS Box Model Presentation
CSS Box Model
5.1 css box model
The Box Model [CSS Introduction]
Css box-model
CSS, CSS Selectors, CSS Box Model

What's hot (17)

PDF
[Basic HTML/CSS] 6. css - box sizing, display, margin, padding
PPTX
Krishan gaurav-sapient bootstrapsession
PPT
Html Expression Web
PDF
Designing Your Next Generation Web Pages with CSS3
DOCX
Vi INFOTECH css-syllabus
KEY
Sass compass
ODP
Cascading Style Sheets - Part 02
PDF
2- Learn Flexbox & CSS Grid / Context
PDF
3- Learn Flexbox & CSS Grid / Container & items
PPTX
CSS3: Common problems and best practices
PDF
CSS Best Practices - tcworld 2018, Scott DeLoach, ClickStart
PDF
Advance Web Designing - Lecture 02 / 30
PDF
1- Learn Flexbox & CSS Grid / Environment setup
PPTX
Website trends 2012 presentation
PPTX
CSS - Text Properties
[Basic HTML/CSS] 6. css - box sizing, display, margin, padding
Krishan gaurav-sapient bootstrapsession
Html Expression Web
Designing Your Next Generation Web Pages with CSS3
Vi INFOTECH css-syllabus
Sass compass
Cascading Style Sheets - Part 02
2- Learn Flexbox & CSS Grid / Context
3- Learn Flexbox & CSS Grid / Container & items
CSS3: Common problems and best practices
CSS Best Practices - tcworld 2018, Scott DeLoach, ClickStart
Advance Web Designing - Lecture 02 / 30
1- Learn Flexbox & CSS Grid / Environment setup
Website trends 2012 presentation
CSS - Text Properties
Ad

Viewers also liked (20)

PDF
Typographic Contrast
PPTX
The CSS Box Model
PDF
CSS Layouting #3 : Box Model
PDF
YMSAT Project Proposal Form
PPTX
Introduction to computers
PPT
Css page layout
PPT
Page Layout 2010
PPTX
Lesson One Fourth Quarter Fourth Year High School CSS Modern Layout and Style
PPT
Introduction to computers new 2010
PPTX
End User Computing (EUC)
PPT
Introduction To Computers
PPTX
CSS Layout Techniques
PPT
Chapter 01 - Introduction to Computers
PDF
Template & Content Control (Basics) - Microsoft Word 2013
PPT
Introduction to computers
PDF
Introduction to computers pdf
PPTX
End User Computing
PDF
Layout with CSS
PPT
Peter Norton’s Introduction to Computers
PPTX
All ms word 2013
Typographic Contrast
The CSS Box Model
CSS Layouting #3 : Box Model
YMSAT Project Proposal Form
Introduction to computers
Css page layout
Page Layout 2010
Lesson One Fourth Quarter Fourth Year High School CSS Modern Layout and Style
Introduction to computers new 2010
End User Computing (EUC)
Introduction To Computers
CSS Layout Techniques
Chapter 01 - Introduction to Computers
Template & Content Control (Basics) - Microsoft Word 2013
Introduction to computers
Introduction to computers pdf
End User Computing
Layout with CSS
Peter Norton’s Introduction to Computers
All ms word 2013
Ad

Similar to CSS Box Model and Dimensions (20)

DOCX
Dynamic progress bar
TXT
This is a test
PDF
Harendra Singh,BCA Third Year
PPTX
Xlrays online web tutorials
PPTX
1-07: The Box Model
PPTX
1 07-the box-model
PPTX
Css presentation lecture 4
PPTX
css-note.pptx
PDF
HTML5 and CSS3 Refresher
DOCX
Week ThreeExpress Holidayscssstyle.csshtml{ height 100.docx
PDF
UI 101
PPTX
Lecture 3: HTML & CSS
PDF
CSS and Layout
PDF
BloggingWithStyle_2008
PDF
BloggingWithStyle_2008
KEY
Getting to Grips with Firebug - Anthony Hortin - WordCamp Sydney
PPTX
Oocss & progressive css3 selectors
PPTX
Unit - 3 CSS(Cascading Style Sheet).pptx
PDF
Intro to HTML & CSS
Dynamic progress bar
This is a test
Harendra Singh,BCA Third Year
Xlrays online web tutorials
1-07: The Box Model
1 07-the box-model
Css presentation lecture 4
css-note.pptx
HTML5 and CSS3 Refresher
Week ThreeExpress Holidayscssstyle.csshtml{ height 100.docx
UI 101
Lecture 3: HTML & CSS
CSS and Layout
BloggingWithStyle_2008
BloggingWithStyle_2008
Getting to Grips with Firebug - Anthony Hortin - WordCamp Sydney
Oocss & progressive css3 selectors
Unit - 3 CSS(Cascading Style Sheet).pptx
Intro to HTML & CSS

More from Gerson Abesamis (20)

PDF
YMSAT Student Primer
PDF
Final Project
PDF
960 Grid System
PDF
Photography Orientation 11-12
PDF
WebDev2 Orientation 11-12
PDF
Photography Class 11-12
PDF
Prewar report
PDF
Typo Graphics
PDF
Web Typography
PDF
WebDev Template Finals
PDF
Css positioning
PDF
Pinhole photography vale
PDF
Interface Design
PDF
CSS Lists and Tables
PDF
CSS Refresher
PDF
Intro to HTML
PDF
Information Architecture
PDF
Site Dev't Team
PDF
Evaluating A Website
PDF
WebDev Finals (3rd Quarter)
YMSAT Student Primer
Final Project
960 Grid System
Photography Orientation 11-12
WebDev2 Orientation 11-12
Photography Class 11-12
Prewar report
Typo Graphics
Web Typography
WebDev Template Finals
Css positioning
Pinhole photography vale
Interface Design
CSS Lists and Tables
CSS Refresher
Intro to HTML
Information Architecture
Site Dev't Team
Evaluating A Website
WebDev Finals (3rd Quarter)

Recently uploaded (20)

DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Yogi Goddess Pres Conference Studio Updates
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Classroom Observation Tools for Teachers
PDF
Computing-Curriculum for Schools in Ghana
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
human mycosis Human fungal infections are called human mycosis..pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
Yogi Goddess Pres Conference Studio Updates
A systematic review of self-coping strategies used by university students to ...
Classroom Observation Tools for Teachers
Computing-Curriculum for Schools in Ghana
Weekly quiz Compilation Jan -July 25.pdf
01-Introduction-to-Information-Management.pdf
VCE English Exam - Section C Student Revision Booklet
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Supply Chain Operations Speaking Notes -ICLT Program
O5-L3 Freight Transport Ops (International) V1.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Anesthesia in Laparoscopic Surgery in India
Final Presentation General Medicine 03-08-2024.pptx
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...

CSS Box Model and Dimensions