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.

Visibility & Opacity | CSS Basics to Advanced lesson | BraveProgrammer
  1. Courses
  2. /
  3. CSS Basics to Advanced

Lesson 14 of 50

·css

Visibility & Opacity

5 mins

Course progress28%

What you'll learn

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

2 points
  • `display:none` removes from the layout and accessibility tree, while `visibility:hidden` only hides visually.
  • `opacity:0` is often paired with CSS transitions for smooth fades.

Two (often confused) ways to hide an element:

PropertyVisual ResultLayout ImpactAccessibility
visibility:hiddenNot visible but still takes up space.No layout change.Still read by screen‑readers.
opacity:0Fully transparent; still participates in layout and can receive pointer events.No layout change.Still read by screen‑readers.
display:noneNeither visible nor present in the DOM tree.Element is removed; surrounding elements collapse.Removed from accessibility tree.

Both visibility:hidden and opacity:0 are handy as animation start‑states, because you can transition them to visible without affecting layout.


Example – Fade‑In Transition Using Opacity

.hidden {
  opacity:0;
  transition:opacity .3s ease;
}
.visible {
  opacity:1;
}
/* JS toggles the class */

Accessibility Reminder

If you hide something from sight but want screen‑reader users to still access it, use visibility:hidden plus aria-hidden="false" or better yet keep the element visible and only visually clip it (clip-path or transform).

Make it stickPractice what you've learned1 quiz · 6 practical tests · Optional activities from CSS Basics to AdvancedBrowse activities
Previous lessonOverflow & ScrollbarsContinue to lesson 15Backgrounds – Images & GradientsBack to CSS Basics to Advanced curriculum