Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 11 pages
Exam (elaborations)

WGU D276 Web Dev Chp 5 Study Guide with Complete Solutions

Document preview thumbnail
Preview 2 out of 11 pages

WGU D276 Web Dev Chp 5 Study Guide with Complete Solutions

Content preview

WGU D276 Web Dev Chp 5 Study Guide with Complete
Solutions


An introduction to the box model
• When a browser displays a webpage, it places each HTML block element in a box.
o Makes it easy to control the spacing, boarders, and other formatting for elements
like headers, sections, footers, headings, and paragraphs.
• Some inline elements like images are placed in a box as well
o To work with boxes, you use the CSS box model

How the box model works
• By default, the box for a block element is as wide as the block that contains it and as tall as
it needs to be based on its content
o However, you can explicitly specify the size of the content area for a block element
by using the height and width properties
o You can also use other properties to set the boarders, margins, and padding for a
block element
• Fixed layout
o The size of a page won’t change if the user changes the size of the browser window
• Margin
o The space between the border or an element and either its containing block or
the element next to it
• Padding
o The space between an element and it border

Formula for calculating the height of a box

Top margin + top border + top padding + <----top of box

Height + <----of content area

Bottom padding + bottom border + bottom margin <----bottom of box

Formula for calculating the width of a box

Left margin + left border + left padding +

Width +

Right padding + right border + right margin

A web page that illustrates the box model
The HTML for a page that uses the box model
<body>
<main>
<h1>San Joaquin Valley Town Hall</h1>
<p>Welcome to San Joaquin Valley Town Hall. We have some fascinating speakers for you this season!

, </p>
</main>
</body>
The CSS for the page
Body {
Border: 3px dotted black;
Margin: 10px;
}
Main {
Border: 3px dotted black;

Width: 500px;
Margin: 20px; /*all four sides*/
Padding: 10px; /*all four sides*/
}
h1, p {

Border: 1px dashed black;
Padding: 10px;
}
h1 {
Margin: .5em 0 .25em; /*.5em top, 0 right and left, .25em
bottom*/ Padding-left: 15px;
}
p{ Margi
n: 0;
Padding-left: 15px;

How to size and space elements
How to set widths and heights
• The two properties you’ll use the most is width and height
o By default, these properties are set to a value of “auto”
▪ The size and content area for the element is automatically adjusted so it's
as wide as the element that contains it and as tall as the content it contains
• To change that, you use the height and width properties
o Can be set to absolute or relative values

Document information

Uploaded on
August 15, 2026
Number of pages
11
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$16.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
ALVINK2022
4.3
(91)
Sold
259
Followers
157
Items
11385
Last sold
1 month ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions