CS396: Spring 2022

Intro to Web Development

CS396: Spring 2022

CSS Resources > 5. The Box Model

Login to LinkedIn Learning via Northwestern

Every element in web design is a rectangular box. The box model refers to some of the properties that control the layout of these boxes (width, height, margin, padding, border, and box-sizing). The CSS Tricks website has a nice description of it.

Common Box Model properties

.page-section {
    box-sizing: border-box;
    border: dotted 1px #CCC; 
    width: 50vh;
    height: 50vh;   
    padding: 10px;
    /*
    Alternative syntax:
    padding-top: 10px;
    padding-right: 10px;
    padding-bottom: 10px;
    padding-left: 10px;
    */
    margin: 10px;
    /*
    Alternative syntax:
    margin-top: 10px;
    margin-right: 10px;
    margin-bottom: 10px;
    margin-left: 10px;
    */
}
Intro to the box model 1:07
Inline, block, and display 3:06
The box model properties 2:06
The box properties syntax and usage 4:07
Debugging the box model 3:28
Padding, margin, & border 5:34
Margins and layouts 3:03