IS117 Ch 5 - How to use the CSS box model

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/16

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:50 PM on 3/25/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

17 Terms

1
New cards

the css content-box model diagram

content —> padding —> border —> margin

all of these added up on OUTSIDE of content box is the overall size of the box

<p>content —&gt; padding —&gt; border —&gt; margin</p><p>all of these added up on OUTSIDE of content box is the overall size of the box</p>
2
New cards

content box

box-sizing: content-box;. In this mode, when you set a width, you are only setting the width of the content area. If you then add padding or a border, they are added on top of that width, making the element physically larger than you intended.

The Math: Actual Width = width + padding + border

3
New cards

automatic box-sizing property

box-sizing: content-box;

4
New cards

box-sizing: border-box;

everything gets added INWARDS

the width you set is the final width

the width you specify includes the content, the padding, and the border. If you add padding,

the browser shrinks the content area to make room for it, keeping the total width of the element exactly what you defined.

The Math: Actual Width = width (padding and border are absorbed inside)

5
New cards

reset selector

a universal selector that resets properties for the whole page, essentially “resetting” it

  • example below: eliminates inconsistent default browser spacing caused by padding and borders.

  • Creates a clean, predictable "blank canvas" where an element's size matches exactly what you set in your CSS.

*{

margin: 0;

padding: 0;

box-sizing: border-box;

}

6
New cards

how to use a reset style sheet

1. Download the CSS file for the style sheet from the internet.

2. Save the CSS file in the correct location.

3. Code a <link> element for the reset style sheet in each HTML document before the other style sheets.

7
New cards

width: 90%;

sets to 90% of the parent it is nested in!

ex. A <div> inside a <body> will be 90% of the body. But if you put a small box inside a medium box, the small box will only be 90% of that medium box.

8
New cards

properties for setting borders and what they do

border

border-side

border-width

border-style

border-color

border-side-width

border-side-style

border-side-color

border all four sides

border-sideNameRLTB set width style color to one specific side only

border-width all 4 sides border thickness

border-style kind of line for all four sides (?)

border-color color of all four sides border

border-sideNameRLTB-width thickness of border for one specific side

border-sideNameRLTB-style line type for a specific side

border-sideNameRLTB-color color for one specific side

9
New cards

syntax for shorthand properties

border: [width] [style] [color];

border-side: [width] [style] [color];

10
New cards

how inset works in here:

color: blue;

border: 1px inset; /* uses the element's color

property */

The inset style is a 3D effect that makes the element look like it is embedded or "sunk" into the page.

The browser automatically takes your currentColor and creates two shades:

  • A darker shade for the top and left edges. (dark blue)

  • A lighter shade for the bottom and right edges. (light blue)

11
New cards

border-radius and box-shadow properties formatting

border-radius: radius; /* applies to all four corners */

border-radius: topLeft topRight lowerRight lowerLeft;

  • ^^ clockwise from top left

box-shadow: horizontalOffset verticalOffset blurRadius

spread color;

12
New cards

properties for working with backgrounds

background

background-color

background-image

background-repeat

background-attachment

background-position

  • background: A shorthand to set all background properties (color, image, size, etc.) in a single line.

  • background-color: Sets the solid fill color behind the element's content.

  • background-image: Sets an image (or multiple images) to display in the background.

  • background-repeat: Determines if the background image tiles/repeats horizontally, vertically, both, or not at all. to fill the allotted space

  • background-attachment: Sets whether the background image scrolls with the page or stays fixed in place.

  • background-position: Sets the starting coordinates of the background image (e.g., center, top left).

ex:

background: blue;

background: blue url("../images/texture.gif");

background: #808080 url("../images/header.jpg")

repeat-y scroll center top;

13
New cards

syntax for shorthand background property

background: [color] [image] [repeat] [attachment] [position];

ex:

background: blue;

background: blue url("../images/texture.gif");

background: #808080 url("../images/header.jpg")

repeat-y scroll center top;

14
New cards

how to control image repetition

background-repeat: repeat; /* repeats both directions */

background-repeat: repeat-x; /* repeats horizontally */

background-repeat: repeat-y; /* repeats vertically */

background-repeat: no-repeat; /* doesn't repeat */

15
New cards

how to control image position

background-position: left top; /* 0% from left, 0% from top */

background-position: center top; /* centered horizontally, 0% from top */

background-position: 90% 90%; /* 90% from left, 90% from top */

16
New cards

how to control image scrolling

background-attachment: scroll; /* image moves as you scroll */

background-attachment: fixed; /* image does not move as you scroll */

17
New cards

syntax for a linear gradient background image property

background-image: linear-gradient(direction, color %, color %, ... );

Explore top notes

note
Traffic Signals
Updated 429d ago
0.0(0)
note
Rhetoric Test
Updated 500d ago
0.0(0)
note
Matter in our surroundings
Updated 699d ago
0.0(0)
note
Trends in the Periodic Table_2
Updated 484d ago
0.0(0)
note
Social Skills Vocabulary
Updated 429d ago
0.0(0)
note
BIO315 - Cell Bio
Updated 537d ago
0.0(0)
note
Traffic Signals
Updated 429d ago
0.0(0)
note
Rhetoric Test
Updated 500d ago
0.0(0)
note
Matter in our surroundings
Updated 699d ago
0.0(0)
note
Trends in the Periodic Table_2
Updated 484d ago
0.0(0)
note
Social Skills Vocabulary
Updated 429d ago
0.0(0)
note
BIO315 - Cell Bio
Updated 537d ago
0.0(0)

Explore top flashcards

flashcards
Introduction to Basic Immunology
40
Updated 1226d ago
0.0(0)
flashcards
European Exploration in Georgia
33
Updated 575d ago
0.0(0)
flashcards
Earth science chapter 24 and 25
27
Updated 614d ago
0.0(0)
flashcards
GUMS M2.5 Flashcards
20
Updated 135d ago
0.0(0)
flashcards
50 and 51 study guide
60
Updated 426d ago
0.0(0)
flashcards
CCU Intro to Lit Poetry Notes
38
Updated 791d ago
0.0(0)
flashcards
Lesson 1: 学中文
27
Updated 1176d ago
0.0(0)
flashcards
Introduction to Basic Immunology
40
Updated 1226d ago
0.0(0)
flashcards
European Exploration in Georgia
33
Updated 575d ago
0.0(0)
flashcards
Earth science chapter 24 and 25
27
Updated 614d ago
0.0(0)
flashcards
GUMS M2.5 Flashcards
20
Updated 135d ago
0.0(0)
flashcards
50 and 51 study guide
60
Updated 426d ago
0.0(0)
flashcards
CCU Intro to Lit Poetry Notes
38
Updated 791d ago
0.0(0)
flashcards
Lesson 1: 学中文
27
Updated 1176d ago
0.0(0)