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.

Overflow & Scrollbars | CSS Basics to Advanced lesson | BraveProgrammer
  1. Courses
  2. /
  3. CSS Basics to Advanced

Lesson 13 of 50

·css

Overflow & Scrollbars

6 mins

Course progress26%

What you'll learn

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

3 points
  • `overflow:hidden` can be used for **CSS‑only cropping** and to hide scrollbars.
  • `overflow:auto` gives browsers the ability to add scrollbars when necessary.
  • `scroll-snap` works together with overflow for carousel‑like UX.

The overflow property decides what happens when a child element is larger than its container.

ValueBehaviour
visibleDefault – overflow spills out, no clipping.
hiddenContent outside the box is clipped and not visible. Useful for UI tricks like image cropping.
autoScrollbars appear only when needed.
scrollScrollbars are always present, even if the content fits.
overlay (deprecated)Scrollbars overlay the content without taking space.

You can also control each axis independently with overflow-x / overflow-y.


Example – Horizontal Scroll Gallery (No‑JS Carousel)

.gallery {
  display:flex;                 /* lay items side‑by‑side */
  overflow-x:auto;              /* horizontal scroll when needed */
  gap:1rem;
  padding:1rem;
  scroll-snap-type:x mandatory; /* optional – snaps to each item */
}
.gallery > * { scroll-snap-align:start; }

Tip – Hide Scrollbars visually but keep scrollability

.element { 
  overflow:auto;
  scrollbar-width:none;           /* Firefox */
  -ms-overflow-style:none;       /* IE 10+ */
}
.element::-webkit-scrollbar { display:none; } /* Chrome, Safari */

Perfect for image carousels where the UI provides its own arrows.

Make it stickPractice what you've learned1 quiz · 6 practical tests · Optional activities from CSS Basics to AdvancedBrowse activities
Previous lessonFloating & ClearingContinue to lesson 14Visibility & OpacityBack to CSS Basics to Advanced curriculum