Did you find this useful?
Socialize it today.


CSS Height and Width

Saturday, March 24, 2012

tags CSS

CSS includes several height and width properties to help you specify the dimensions of your HTML elements. There are six different CSS properties that can used to specify the height and width of an element. They are as follows: height, width, min-height, max-height, min-width and max-width. In addition, you can assign the auto and inherit value as well. You can assign each property either a fixed measurement (px,pt,em,etc.) or a percentage value. For example, if you specify a percentage value for the width property, the width of the element you are styling will be set to a percentage of the parent element's width.


PropertyDescriptionValues
heightHeight of an elementauto, measurement, percentage, inherit
widthWidth of an elementauto, measurement, percentage, inherit
min-heightMinimum height of an elementmeasurement, percentage, inherit
min-widthMinimum width of an elementmeasurement, percentage, inherit
max-heightMaximum height of an elementmeasurement, percentage, inherit
max-widthMaximum width of an elementmeasurement, percentage, inherit


Example

The following is an example of a <div> element with a width of 50%. Keep in mind that this div is within another element on the page so the div element's width is not 50% of the screen, but will be 50% of the width of its parent element


This div's width is set to 50%.

Please help us spread the word by socializing it today!

email contact us

Did you find something wrong with the information on this page? Please take a moment to report it to us so that we can continue to improve the quality of the information on this site. Click here to report an issue with this page.



Recommended Books & Training Resources

CSS: The Missing Manual HTML CSS: The Complete Reference HTML CSS and JavaScript Editor