Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Display Property | CSS Basics to Advanced lesson | BraveProgrammer
  1. Courses
  2. /
  3. CSS Basics to Advanced

Lesson 10 of 50

·css

Display Property

9 mins

Course progress20%

What you'll learn

Keep these ideas in mind as you work through the lesson.

3 points
  • `display:none` also removes the element from the accessibility tree – use `visibility:hidden` if you only need visual hiding.
  • `inline-block` is a common choice for button groups and nav items.
  • `flex` and `grid` are modern layout engines; they replace most uses of `float`.

display decides how an element participates in the visual flow of the document.

ValueLayout Behaviour
blockTakes the full width, starts on a new line.
inlineFlows with surrounding text; width/height ignored.
inline-blockLike inline but respects width/height.
flexTurns the element into a Flex container (one‑dimensional, flexible layout).
gridTurns the element into a Grid container (two‑dimensional layout).
noneRemoves the element from the render tree. Not visible, not focusable, not read by screen‑readers.
list-itemGenerates a bullet/number (useful for custom list styling).

When to Use inline-block

Common for button groups, navigation tabs, or icon + text combos where you need a box that behaves like text but still respects dimensions.

.nav-item {
  display:inline-block;
  margin-right:1rem;
}

The Power of flex and grid

Both completely replace old layout tricks (float, inline‑block hacks). Use them for all new UI unless you have a very specific reason to stay with older techniques.

Accessibility Note – display:none

Because display:none removes the element from the accessibility tree, it should only be used for content that truly does not belong in the DOM (e.g., modal dialogs that are closed). If you only need to hide something visually while keeping it readable by assistive tech, use visibility:hidden or opacity:0.

Make it stickPractice what you've learned1 quiz · 6 practical tests · Optional activities from CSS Basics to AdvancedBrowse activities
Previous lessonUnits of MeasurementContinue to lesson 11PositioningBack to CSS Basics to Advanced curriculum