Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape

CSS Display

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 layout

A 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 layout

Inline 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 behavior

Inline-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
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 layout

Flexbox 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 layout

CSS 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
ValueBehaviorCommon Use
blockNew lineSections and containers
inlineSame lineText-level elements
inline-blockInline + dimensionsButtons and small cards
noneRemoved from layoutHide elements
flexFlexible layoutNavigation and rows
gridRows + columnsCards and page layouts
11

Practical Course Layout

Real-world CSS display example
C

Computer Fundamentals

Learn computer basics, hardware, software, operating systems and applications.

View Course →
H

HTML & CSS

Build responsive and professional websites using HTML and CSS.

View Course →
T

Tally Prime

Learn accounting, GST, inventory and practical business applications.

View Course →
13

CSS Display Live Example

Run the practical example
LIVE PREVIEW
`;document.getElementById( "sncecDisplayPreview" ).srcdoc=html;}document.addEventListener( "DOMContentLoaded", function(){sncecDisplayRun();} );

CSS Colors

  • 17/08/2026

CSS Links

  • 17/08/2026

HTML Headings

  • 16/08/2026

Leave a Reply

Your email address will not be published. Required fields are marked *