CSS
HTML
JavaScript
jQuery
PHP
SQL
WordPress
CSS Tutorials

Overview

The CSS width, height, min-width, min-height, max-width, and max-height properties are used to set the size (including minimum/maximum) of an element.

  • width – sets the width of the element
  • height – sets the height of the element
  • min-width – sets the smallest width the element can have
  • min-height – sets the smallest height the element can have
  • max-width – sets the largest width the element can have
  • max-height – sets the largest height the element can have
This element (box) is 100% wide x 80px high

Setting the Size

This is the size that the element will appear on all screens.

				
					div {
    width: 100%;
    height: 80px;
}
				
			
				
					img {
    width: 100%;
    height: auto;
}
				
			

Setting the Minimum and Maximum Size

This is the smallest and largest that an element is to appear on the screen. For instance, if someone is using a very large screen and you simply have the width set to 100%, the content of the element will stretch entirely across the screen, which could look awkward, and be difficult to read. So you set a max-width to something where it will grow with the screen size, but only to a certain point.

Similarly, you may want to set a minimum size for times when having the element smaller would look awkward or perhaps unreadable.

				
					div {
    max-width: 1440px;
    min-width: 325px;
}
				
			

Width and Height Properties

We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.

CSS
HTML
JavaScript
jQuery
PHP
SQL
WordPress

Why 1SMARTchicken?

This site was built and is maintained to benefit my autistic son.
See More →

My Son's Name is Johnny

He was diagnosed as autistic quite late, at age four...
His story

Buy Me a Coffee

Thanks for your support!

Feedback

If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.