SyntaxStudy
Sign Up
CSS Display & Visibility
CSS Beginner 1 min read

Display & Visibility

CSS Display & Visibility

The display Property

ValueBehaviour
blockTakes full width, starts on new line (div, p, h1…)
inlineFlows with text, no width/height (span, a…)
inline-blockFlows inline but respects width/height/padding
noneRemoves element from layout (not visible)
flexEnables Flexbox on the container
gridEnables CSS Grid on the container

visibility vs display: none

  • visibility: hidden — hides but keeps the space
  • display: none — removes from layout entirely
Example
/* Force block */
span.label { display: block; }

/* Inline-block: sizing + inline flow */
.badge {
  display: inline-block;
  padding: 4px 10px;
  background: #6366f1;
  color: white;
  border-radius: 999px;
}

/* Hide completely */
.hidden  { display: none; }

/* Hide but keep space */
.ghost   { visibility: hidden; }