
- 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
CSS3 Box Width with Box-Sizing
Use the box-sizing property to change not only the width of element, but the height.
Following is the code for box width with box-sizing using CSS3 −
Example
<!DOCTYPE html> <html> <head> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } div { width: 200px; height: 200px; display: inline-block; } .contentBox { padding: 50px; border: 1px solid rgb(255, 0, 128); } .borderBox { box-sizing: border-box; padding: 50px; border: 1px solid rgb(194, 0, 194); } </style> </head> <body> <h1>Box sizing example using CSS</h1> <div class="contentBox"> This div doesn't have box sizing property that's why it looks bigger </div> <div class="borderBox"> This div has box sizing property </div> </body> </html>
Output
The above code will produce the following output −
- Related Articles
- Creating Layouts with Box-Sizing using CSS3
- CSS2 sizing property vs CSS3 box sizing property
- CSS Box Sizing Property
- CSS3 Flexible Box Layouts
- Text in Transparent Box using CSS3
- Set the width of a box with CSS
- Set the maximum width that a box can be with CSS
- Set the minimum width that a box can be with CSS
- How to create CSS3 Box and Text Shadow Effects?
- Adjust the width of box in boxplot in Python Matplotlib
- How to create boxplot in base R with higher width of the box lines?
- Create a transparent box with CSS
- What is the difference between a white box, black box, and gray box testing?
- Differences between Black Box Testing vs. White Box Testing.
- Differences between White Box Testing and Grey Box Testing.

Advertisements