- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Selectors
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Border Block
- CSS - Border Inline
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursor
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS - Inline Block
- CSS - Dropdowns
- CSS - Visibility
- CSS - Overflow
- CSS - Clearfix
- CSS - Float
- CSS - Arrows
- CSS - Resize
- CSS - Quotes
- CSS - Order
- CSS - Position
- CSS - Hyphens
- CSS - Hover
- CSS - Display
- CSS - Focus
- CSS - Zoom
- CSS - Translate
- CSS - Height
- CSS - Hyphenate Character
- CSS - Width
- CSS - Opacity
- CSS - Z-Index
- CSS - Bottom
- CSS - Navbar
- CSS - Overlay
- CSS - Forms
- CSS - Align
- CSS - Icons
- CSS - Image Gallery
- CSS - Comments
- CSS - Loaders
- CSS - Attr Selectors
- CSS - Combinators
- CSS - Root
- CSS - Box Model
- CSS - Counters
- CSS - Clip
- CSS - Writing Mode
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - Pointer Events
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS Advanced
- CSS - Grid
- CSS - Grid Layout
- CSS - Flexbox
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Paged Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS - Image Sprites
- CSS - Important
- CSS - Data Types
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS - Rounded Corner
- CSS - Border Images
- CSS - Multi Background
- CSS - Color
- CSS - Gradients
- CSS - Box Shadow
- CSS - Box Decoration Break
- CSS - Caret Color
- CSS - Text Shadow
- CSS - Text
- CSS - 2d transform
- CSS - 3d transform
- CSS - Transition
- CSS - Animation
- CSS - Multi columns
- CSS - Box Sizing
- CSS - Tooltips
- CSS - Buttons
- CSS - Pagination
- CSS - Variables
- CSS - Media Queries
- CSS - Functions
- CSS - Math Functions
- CSS - Masking
- CSS - Shapes
- CSS - Style Images
- CSS - Specificity
- CSS - Custom Properties
- CSS Responsive
- CSS RWD - Introduction
- CSS RWD - Viewport
- CSS RWD - Grid View
- CSS RWD - Media Queries
- CSS RWD - Images
- CSS RWD - Videos
- CSS RWD - Frameworks
- 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 - block-size Property
The block-size property of CSS determines the horizontal or vertical size of an element's block, based on the writing mode of the element. It relates to the width or the height properties of CSS, based on the value of writing-mode.
When the writing mode is vertically orientated, the value of block-size relates to the width of the element, else it relates to the height of the element.
Possible Values
The CSS property block-size takes the same value as the width and height properties.
Applies To
All elements but non-replaced inline elements, table rows, and row groups.
Syntax
Following are the different ways in which the block-size can be declared:
Length Value
block-size: 100px; block-size: 20em;
percentage Value
block-size: 45%;
Keyword Value
block-size: max-content; block-size: min-content; block-size: fit-content; block-size: auto;
Global Value
block-size: inherit; block-size: initial; block-size: revert; block-size: revert-layer; block-size: unset;
CSS block-size - Using Length Values
Following example demonstrates the output with writing-mode: vertical-rl and block-size is given a length value:
<html> <head> <style> .container { writing-mode: vertical-rl; background-color: pink; border: 2px solid blue; display: inline-block; } .sampleText-px { block-size: 100px; } .sampleText-em { block-size: 20em; } </style> </head> <body> <h2>block-size - length value</h2> <div class="container sampleText-px">Sample Text-px</div> <div class="container sampleText-em">Sample Text-em</div> </body> </html>
Following example demonstrates the output with writing-mode: horizontal-tb and block-size is given a length value:
<html> <head> <style> .container { writing-mode: horizontal-tb; background-color: pink; border: 2px solid blue; display: inline-block; } .sampleText-px { block-size: 100px; } .sampleText-em { block-size: 20em; } </style> </head> <body> <h2>block-size - length value with writing-mode: horizontal-tb</h2> <div class="container sampleText-px">Sample Text-px</div> <div class="container sampleText-em">Sample Text-em</div> </body> </html>
CSS block-size - Using Percentage Values
Following example demonstrates the output with writing-mode: vertical-rl and block-size is given as a percentage value:
<html> <head> <style> .container { writing-mode: vertical-rl; background-color: pink; border: 2px solid blue; display: inline-block; } .sampleText-10per { block-size: 10%; } .sampleText-65per { block-size: 65%; } </style> </head> <body> <h2>block-size - percentage value with writing-mode: vertical-rl</h2> <div class="container sampleText-10per">Sample Text-10%</div> <div class="container sampleText-65per">Sample Text-65%</div> </body> </html>
Following example demonstrates the output with writing-mode: horizontal-tb and block-size is given as a percentage value:
<html> <head> <style> .container { writing-mode: horizontal-tb; background-color: pink; border: 2px solid blue; display: inline-block; } .sampleText-10per { block-size: 10%; } .sampleText-65per { block-size: 65%; } </style> </head> <body> <h2>block-size - percentage value with writing-mode: horizontal-tb</h2> <div class="container sampleText-10per">Sample Text-10%</div> <div class="container sampleText-65per">Sample Text-65%</div> </body> </html>
CSS block-size - Using Keyword Values
Following example demonstrates the output with writing-mode: vertical-rl and block-size is given as a keyword value:
<html> <head> <style> .container { writing-mode: vertical-rl; background-color: pink; border: 2px solid blue; display: inline-block; } .sampleText-auto { block-size: auto; } .sampleText-max { block-size: max-content; } .sampleText-min { block-size: min-content; } .sampleText-fit { block-size: fit-content; } </style> </head> <body> <h2>block-size - keyword value with writing-mode: vertical-rl</h2> <div class="container sampleText-auto">Sample Text - auto</div> <div class="container sampleText-max">Sample Text - max-content</div> <div class="container sampleText-min">Sample Text - min-content</div> <div class="container sampleText-fit">Sample Text - fit-content feature</div> </body> </html>
Following example demonstrates the output with writing-mode: horizontal-tb and block-size is given as a keyword value:
<html> <head> <style> .container { writing-mode: horizontal-tb; background-color: pink; border: 2px solid blue; display: inline-block; } .sampleText-auto { block-size: auto; } .sampleText-max { block-size: max-content; } .sampleText-min { block-size: min-content; } .sampleText-fit { block-size: fit-content; } </style> </head> <body> <h2>block-size - keyword value with writing-mode: horizontal-tb</h2> <div class="container sampleText-auto">Sample Text - auto</div> <div class="container sampleText-max">Sample Text - max-content</div> <div class="container sampleText-min">Sample Text - min-content</div> <div class="container sampleText-fit">Sample Text - fit-content feature</div> </body> </html>
To Continue Learning Please Login
Login with Google