🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to CSS Notes
Topic #31

CSS Height / Width


CSS Height and Width

The CSS height and width properties are used to set the height and width of an element.


CSS Set height and width

The height and width properties are used to set the height and width of an element.

The height and width do not include padding, borders, or margins. It sets the height and width of the area inside the padding, border, and margin of the element.


CSS height and width Values

The height and width properties can have the following values:

  • auto - This is default. The browser calculates the height and width
  • length - Defines the height or width in px, cm, em, etc.
  • % - Defines the height or width in percent of the containing block
  • initial - Sets the height or width to its default value
  • inherit - The height or width will be inherited from its parent value

CSS height and width Examples

Example

div {
  height:
200px;
  width: 50%;
  background-color: powderblue;
}

Example

div {

height:
100px;
  width: 500px;
  background-color: powderblue;
}

Note: Remember that the height and width properties do not include padding, borders, or margins! They set the height/width of the area inside the padding, border, and margin of the element!

Want to go beyond the notes?

Join CodingNow 2.0's CSS course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

CSS Height / Width – FAQs

Quick answers about learning CSS Height / Width in CSS.

This free note from CodingNow 2.0 explains CSS Height / Width in CSS — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every CSS topic on CodingNow 2.0, including CSS Height / Width, is 100% free with no signup required.
With focused practice, most students grasp CSS Height / Width in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now