Locked lesson.
About this lesson
Exercise files
Download this lesson’s related exercise files.
Height and Width.docx58.6 KB Height and Width - Solution.docx
58.8 KB
Quick reference
Height and Width
To designate the height and width of an element we use the height and width property.
When to use
Any time you want to explicitly size an element.
Instructions
To set the width of a thing and the height of a thing:
height: 200px;
width: 500px;
Height and width can be designated with pixels (px) or percentages (%).
To set the maximum width, use the max-width property:
max-width: 50%;
Max-width can use pixels or percentages.
Whenever you use the hieght and the width they do not take into account padding and margins.
Hints & tips
- To set the height of an element, use the height property.
- To set the width of an element, use the width property.
- Height and width can be pixels or percentages.
- To set the max width, use the max-width property in pixels or percentages.
Lesson notes are only available for subscribers.