css · level 1 · unit 6 · lesson 1
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
width and height set the size of a box.
A box normally stretches as wide as the space it sits in, and grows as tall as its content. width and height let you choose the size yourself, like width: 200px.
They set the size of the . Padding and borders are added on top, so a 200px box with 10px of padding on each side takes up 220px across.
An is a picture on the page. The <img> tag shows one, and its src names the file, like src="cat.svg". Set its width to make it bigger or smaller.
<img src="cat.svg" alt="A sleepy cat">
<div class="box">A box 200px wide</div> img {
width: 120px;
}
.box {
width: 200px;
height: 80px;
background-color: peachpuff;
} Press show my page to see it here.
<img> has no closing tag, and its alt describes the picture for anyone who cannot see it.
guess first
Width plus padding. How wide is it across?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
<div class="banner">Welcome</div> .banner {
width: 200px;
padding: 10px;
background-color: skyblue;
}
your turn
Your turn. Make a sticky note.
Give the sticky note a width and a height, each between 120px and 200px. Make them match for a perfect square.
the page you’re styling
<div class="sticky">Buy more biscuits</div>your css
Press show my page to see it here.
- the note is 120px to 200px widenot checked yet
- the note is 120px to 200px tallnot checked yet
fix it
The bar is too thin. Can you fix it?
the page you’re styling
<div class="bar">Loading...</div>your css
Press show my page to see it here.
- the bar is 40px tallnot checked yet
- the bar is 300px widenot checked yet
- The width works but the height does not. Read the property names slowly.
- Two letters near the end of one property have swapped places.
- Change
heigthtoheight, then press run.
nailed it
you set the size of your boxes. :D
widthandheightset the size of a box.- Padding and borders are added on top of the width.
<img>shows a picture, andwidthresizes it.
new words in your collection
- content area
- image
This lesson isn’t saved. A free account remembers every lesson you finish.