Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

18. CSS - Dimension

Lesson 18 of 34 in the free CSS Customization: Zero to Hero notes on Siksha Sarovar, written by Rohit Jangra.

CSS Height, Width and Max-width

The CSS height and width properties are used to set the height and width of an element. The max-width property is used to set the maximum width of an element.

1. Height and Width

The height and width properties may take the following values:

  • auto: Default. The browser calculates the height and width.
  • length: Defines the height/width in px, cm, etc.
  • %: Defines the height/width in percent of the containing block.
  • initial: Sets this property to its default value.
  • inherit: Inherits this property from its parent element.

Note: The height and width values do not include padding, borders, or margins.

2. Max-width

The problem with the width tag occurs when the browser window is smaller than the width of the element. The browser then adds a horizontal scrollbar to the page. Using max-width instead, in this situation, will improve the browser's handling of small windows. This is important when making a site usable on small devices.

3. Min-width and Min-height

  • min-width: Defines the minimum width of an element.
  • min-height: Defines the minimum height of an element.
div {
  max-width: 500px;
  min-height: 200px;
  background-color: yellow;
}