overflow

Controls how overflowing content is handled in a container. Determines whether to scroll, clip, or display as-is, and also affects border-radius clipping and block formatting context creation.

Class List

ClassCSSDescription
ovoverflow: visibledefault; overflowing content displayed outside container
ohoverflow: hiddenclips overflowing content; no scrollbars
osoverflow: scrollalways shows scrollbars; scrollbar persists even without overflow
oaoverflow: autoshows scrollbar only when overflowing; most commonly used
ocoverflow: clipclips overflowing content; also blocks programmatic scrolling

Visual Comparison

Compares the difference of each overflow value by placing overflowing text in a fixed-size container (w20rem h10rem).

Visible — ov

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident.

default; content overflows outside the container

Hidden — oh

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident.

overflowing portion is clipped and hidden; no scrolling

Scroll — os

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident.

scrollbar is always displayed

Auto — oa

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident.

scrollbar appears only when content overflows

Clip — oc

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident.

similar to hidden but also blocks programmatic scrolling

Per-Axis Control — overflow-x / overflow-y

Use dedicated overflow-x and overflow-y classes to control horizontal and vertical axes independently.

ClassCSSDescription
oxvoverflow-x: visiblehorizontal overflow displayed as-is
oxaoverflow-x: autohorizontal scroll when overflowing
oxhoverflow-x: hiddenhorizontal overflow clipped
oxsoverflow-x: scrollhorizontal scrollbar always displayed
oxcoverflow-x: cliphorizontal overflow clipped (programmatic scrolling also blocked)
oyvoverflow-y: visiblevertical overflow displayed as-is
oyaoverflow-y: autovertical scroll when overflowing
oyhoverflow-y: hiddenvertical overflow clipped
oysoverflow-y: scrollvertical scrollbar always displayed
oycoverflow-y: clipvertical overflow clipped (programmatic scrolling also blocked)

Class Details

ovoverflow: visible

Default value. Overflowing content is displayed outside the container. Rarely set explicitly, but used to reset other overflow values.

<!-- Default reset (restore child when parent has oh) -->
<div class="oh br8px">
  <div class="ov">This child is reset to overflow: visible</div>
</div>

ohoverflow: hidden

Clips overflowing content. Cleanly clipped without scrollbars, and creates a new block formatting context (BFC). Commonly used to solve border-radius clipping issues.

<!-- border-radius clipping -->
<div class="oh br8px">
  <img src="photo.jpg" class="w100p db" />
  <div class="p16px">Image is clipped to rounded corners</div>
</div>

<!-- Text truncation (single line) -->
<p class="oh wsn toe w20rem">
  This text is shown in one line and truncated with ... if it overflows
</p>

<!-- Clearfix (creates BFC) -->
<div class="oh">
  <div class="fl w50p">Float Left</div>
  <div class="fl w50p">Float Right</div>
  <!-- oh automatically resolves parent height -->
</div>

Common Usage

oh br8pxborder-radius clipping — solves child elements breaking through rounded corners
ohclearfix — solves parent not capturing floated child height (creates BFC)
oh wsn toetext ellipsis — clips single-line text and shows ...

Caution

oh clips content without scrolling, so users cannot access clipped content. Use oa if scrolling is needed.

osoverflow: scroll

Always shows scrollbars even when content does not overflow. Useful for preventing layout shifts, but oa is more appropriate in most cases.

<!-- Always show scrollbar -->
<div class="os h20rem p16px">
  <p>Scrollbar is shown even with little content.</p>
  <p>Useful for preventing layout shift.</p>
</div>

oaoverflow: auto

Shows scrollbars only when content overflows. The most commonly used overflow value, suitable for sidebars, modal interiors, code blocks, etc.

<!-- Sidebar scroll -->
<aside class="oa h100vh p2rem">
  <nav>Long menu list...</nav>
</aside>

<!-- Modal inner scroll -->
<div class="modal pa t50p l50p bg18181B br8px p2rem">
  <div class="oa maxh50vh">
    <p>Scrollable when long content is added...</p>
  </div>
</div>

<!-- Wide table horizontal scroll -->
<div class="oxa w100p">
  <table class="w200rem">...</table>
</div>

Common Combinations

oa h40remfixed-height scroll area (sidebar, panel)
oa maxh50vhmax-height limited scroll (modal interior)
oxahorizontal scroll only (wide tables, code blocks)
oyavertical scroll only (lists, chat windows)

ocoverflow: clip

Similar to oh in clipping overflowing content, but also completely blocks programmatic scrolling. Another difference is that it does not create a BFC.

<!-- Programmatic scroll also blocked -->
<div class="oc w20rem h10rem">
  Overflowing content is clipped, and JavaScript scrollTo() does not work.
</div>

oh vs oc

oh allows scrolling via JavaScript's scrollTo() and creates a BFC. oc blocks programmatic scrolling and does not create a BFC.

Common Patterns

The oh br8px combination solves the issue of child elements breaking through the parent's border-radius.

<!-- ✅ border-radius clipping Pattern -->
<div class="oh br8px b1pxsolid27272A">
  <img src="cover.jpg" class="w100p db" />
  <div class="p16px">
    Child image does not break through parent rounded corners
  </div>
</div>

<!-- ❌ Without oh, child ignores border-radius -->
<div class="br8px b1pxsolid27272A">
  <img src="cover.jpg" class="w100p db" />
  <div class="p16px">Image breaks through the corners</div>
</div>

<!-- Scrollable sidebar -->
<div class="dg gtc25rem-1fr h100vh">
  <aside class="oa py2rem px16px">
    <nav>Long menu list</nav>
  </aside>
  <main class="oa p2rem">Main Content</main>
</div>

Tips & Notes

oh clips content

oh clips overflowing content without scrollbars. Since users cannot access clipped content, use oa if scrolling is needed.

oa = scroll only when needed

oa shows scrollbars only when content overflows. Since os always shows scrollbars, oa is more appropriate in most cases.

oh creates a new Block Formatting Context (BFC)

oh creates a BFC, also acting as a clearfix for floated elements. Solves the issue where child floats prevent the parent from capturing height.