
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS Dimension Properties
Several properties like width, height, max-height, etc. in CSS allow user to control the dimensions of element content box.
Let’s see an example for the CSS max-height property −
Example
<!DOCTYPE html> <html> <head> <title>CSS max-height</title> <style> form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } #containerDiv { margin: 0 auto; max-height: 150px; } </style> </head> <body> <form> <fieldset> <legend>CSS max-height</legend> <div id="containerDiv"> <img id="image" src="https://www.tutorialspoint.com/machine_learning_with_python/images/machine-learning-with-python-mini-logo.jpg"> </div> </fieldset> </form> </body> </html>
Output
Before max-height was defined −
After max-height was defined −
Let’s see another example of CSS min-width property −
Example
<!DOCTYPE html> <html> <head> <title>CSS min-width Property</title> </head> <style> * { padding: 2px; margin:5px; } button { border-radius: 10px; } #containerDiv { width:70%; margin: 0 auto; padding:20px; background-image: linear-gradient(135deg, #dc3545 0%, #9599E2 100%); text-align: center; border-radius: 10px; } .contentDiv{ min-width:200px; border: 1px solid black; } </style> <body> <div id="containerDiv"> <div class="contentDiv"> This is paragraph 1 with some dummy text. </div> <div class="contentDiv"> This is paragraph 2 with some dummy text. </div> <div class="contentDiv"> This is paragraph 2 with some dummy text. </div> <button onclick="add()" class="btn">Set minWidth</button> </div> <script> function add() { document.querySelectorAll('.contentDiv')[1].style.minWidth = "100%"; } </script> </body> </html>
Output
Before clicking ‘Set minWidth’ button −
After clicking ‘Set minWidth’ button −
- Related Articles
- CSS Border Properties
- CSS Background Properties
- CSS Margin Properties
- Aural Media CSS Properties
- CSS flex container properties
- CSS positioning related properties
- CSS flex item properties
- Font Properties in CSS
- Reset all properties with CSS
- Essential CSS Properties for Styling Tables
- How to apply CSS properties using jQuery?
- Set all border-radius properties with CSS
- The width and height properties in CSS
- Understanding clientHeight, offsetHeight & scrollHeight Properties in CSS
- How to Play and Pause CSS Animations using CSS Custom Properties?

Advertisements