Currently Empty: ₹0.00
CSS Display
CSS CODES & EXAMPLES
CSS Display
Learn how the CSS display property controls the layout, visibility and positioning behavior of HTML elements.
01
What is CSS Display?
Control how an element behaves in a layout
The CSS display property determines how an HTML element
is rendered and how it participates in the page layout.
block
Starts on a new line and normally takes the available width.
inline
Stays within the same line and uses only the required width.
inline-block
Behaves inline while allowing width and height.
none
Removes the element from the layout completely.
02
display: block
Block-level layoutA block element starts on a new line and normally occupies the available horizontal space.
block.css
.box {
display: block;
width: 250px;
padding: 20px;
background: #1769d5;
color: white;
}BLOCK 1
BLOCK 2
BLOCK 3
03
display: inline
Inline layoutInline elements remain on the same line whenever enough horizontal space is available.
inline.css
.box {
display: inline;
background: #1769d5;
color: white;
}
INLINE 1
INLINE 2
INLINE 3
04
display: inline-block
Inline + block behaviorInline-block elements stay beside each other while allowing width, height, padding and margin to be applied.
inline-block.css
.box {
display: inline-block;
width: 180px;
height: 100px;
padding: 20px;
margin: 10px;
}BOX 1
BOX 2
BOX 3
05
display: none
Completely hide an element
display: none; removes the element from the page layout.
It does not reserve any space.
none.css
.hidden {
display: none;
}
06
visibility: hidden
Hide while keeping the space
Unlike display: none, visibility hidden makes an element
invisible while preserving its original layout space.
visibility.css
.hidden {
visibility: hidden;
}BOX 1
HIDDEN
BOX 3
07
display: flex
One-dimensional flexible layoutFlexbox is useful for arranging elements in rows or columns and controlling alignment and spacing.
flex.css
.container {
display: flex;
gap: 15px;
justify-content: center;
align-items: center;
}1
2
3
4
08
Flex Direction
Change the main axis
flex-direction.css
.container {
display: flex;
flex-direction: row;
}
.container {
display: flex;
flex-direction: column;
}
row
1
2
3
column
1
2
3
09
display: grid
Two-dimensional layoutCSS Grid allows you to create rows and columns and is ideal for structured page layouts.
grid.css
.container {
display: grid;
grid-template-columns:
repeat(3, 1fr);
gap: 15px;
}1
2
3
4
5
6
10
Display Property Reference
Quick revision table| Value | Behavior | Common Use |
|---|---|---|
block | New line | Sections and containers |
inline | Same line | Text-level elements |
inline-block | Inline + dimensions | Buttons and small cards |
none | Removed from layout | Hide elements |
flex | Flexible layout | Navigation and rows |
grid | Rows + columns | Cards and page layouts |
11
Practical Course Layout
Real-world CSS display exampleComputer Fundamentals
Learn computer basics, hardware, software, operating systems and applications.
View Course →HTML & CSS
Build responsive and professional websites using HTML and CSS.
View Course →Tally Prime
Learn accounting, GST, inventory and practical business applications.
View Course →
12
Practice Task
Test your CSS skills🎯 Build a Course Grid
Create three course cards using CSS Grid.
- Use
display: grid; - Create three equal columns.
- Add
gap: 20px; - Add padding and border.
- Use
border-radius. - Add a course title and description.
- Add a View Course button.
13
CSS Display Live Example
Run the practical example
LIVE PREVIEW



