Skip to main content
D
CSS
CSS Height and Width

CSS Height and Width

CSS controls the exact height and width of an element.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

CSS defines the physical dimensions of an element's content area. These properties do not include padding, borders, or margins. Setting these values ensures an element takes up the correct amount of space on the screen.

Example

Example
1/* this sets dimensions */
2div {
3  width: 50%;
4  height: 200px;
5  background-color: blue;
6}

Key Points

  • The `width` sets the horizontal size.
  • The `height` sets the vertical size.
  • Dimensions exclude padding and borders by default.
  • You can use pixels or percentages.

Up Next

Continue your journey with the next topic.

Go to CSS Box Model