CSS TutorialLesson 12Free preview
CSS Height / Width
This lesson is part of CSS · All levels
Summary
The height and width properties determine the size of the content area of an element. Its value can be absolute length (px), relative (%), or keywords such as auto, min-content, and fit-content. The block elements are usually the width of the container, so the width needs to be adjusted manually if a specific width is desired.
Key points
- Height sets the height and width sets the width of the element.
- The % value is calculated against the width or height of the parent.
- The auto value makes the browser calculate the size based on the content of the elements.
- Min-height, min-width, max-height, and max-width limit the size without forcing the size to be fixed.
- Elements with a certain width plus a left-right margin can be centered.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.