CSS background-repeat-y Property

The background-repeat-y property controls how an element's background images repeat along the vertical axis.

It can repeat image tiles continuously, display a single tile, distribute complete tiles with spacing, or resize tiles to fit the available height. Unlike the repeat-y value of background-repeat, this longhand property changes only vertical repetition and leaves horizontal repetition controlled by background-repeat-x.

background-repeat-y Syntax

selector {
  background-repeat-y: repeat;
}

The property accepts a vertical repetition keyword or a comma-separated list of values for multiple background image layers.

.repeat-vertical {
  background-repeat-y: repeat;
}
.single-vertical-tile {
  background-repeat-y: no-repeat;
}
.spaced-vertical-tiles {
  background-repeat-y: space;
}
.resized-vertical-tiles {
  background-repeat-y: round;
}
.multiple-vertical-styles {
  background-repeat-y: no-repeat, repeat;
}

The property also accepts CSS-wide values such as inherit, initial, revert, revert-layer, and unset.

Each value controls only vertical repetition. Horizontal repetition is determined separately by background-repeat-x.

Property Values

Value Description
repeat Repeats background image tiles vertically. Partial tiles may appear at the painting area's edges.
no-repeat Displays one tile vertically without creating additional copies along that axis.
space Distributes complete tiles vertically with equal spacing when at least two tiles fit.
round Adjusts tile heights so an integer number of tiles fits within the background positioning area's height.
comma-separated list Assigns different vertical repetition styles to individual background image layers.

The property applies to all elements, is not inherited, and has an initial value of repeat. Its computed value is a list of repetition keywords, and its animation type is discrete.

The keywords repeat-x and repeat-y are values of the background-repeat shorthand, not valid values of background-repeat-y.

How background-repeat-y Works

The browser determines the rendered size and position of each background image before applying its vertical repetition style.

.patterned-panel {
  width: 300px;
  height: 180px;
  background-image: url("pattern.png");
  background-size: 40px 40px;
  background-repeat-x: no-repeat;
  background-repeat-y: repeat;
}

The background image is rendered at 40 by 40 pixels and repeated vertically. Horizontal repetition is disabled, so the result is one column of tiles.

Independent Repetition Axes

Setting background-repeat-y does not automatically disable horizontal repetition. If background-repeat-x remains at its initial value of repeat, the image may repeat in both directions.

.repeat-both-directions {
  background-repeat-x: repeat;
  background-repeat-y: repeat;
}

This is equivalent to background-repeat: repeat.

Background Tiles

Each copy of a repeated background image is called a tile. The height of the rendered tile determines how many copies fit vertically within the positioning area.

For example, a 200-pixel-tall positioning area can accommodate five complete 40-pixel-tall tiles.

Repetition Does Not Change Element Layout

Repeating an image vertically does not increase the element's height or create additional HTML content. The image remains part of the element's background.

The repeat Value

The repeat value repeats background image tiles continuously along the vertical axis.

.vertical-pattern {
  background-image: url("pattern.png");
  background-size: 40px 40px;
  background-repeat-x: no-repeat;
  background-repeat-y: repeat;
}

The image repeats from top to bottom, creating a vertical column of tiles.

Partial Tiles

When the available height is not an exact multiple of the tile height, partial tiles may appear at the edges of the background painting area.

For example, a 250-pixel-tall area using 40-pixel tiles can display six complete tiles and part of another tile, depending on the background position.

Creating a Decorative Side Strip

.side-pattern {
  min-height: 250px;
  background-image: url("stripe.png");
  background-size: 12px 40px;
  background-repeat-x: no-repeat;
  background-repeat-y: repeat;
  background-position: left top;
}

The image repeats vertically along the left edge of the element.

Use repeat for continuous vertical textures, decorative side patterns, and other designs where partial edge tiles are acceptable.

The no-repeat Value

The no-repeat value prevents background images from repeating vertically.

.single-row {
  background-image: url("pattern.png");
  background-repeat-x: repeat;
  background-repeat-y: no-repeat;
}

The image appears in one horizontal row because vertical repetition is disabled while horizontal repetition remains enabled.

Displaying One Background Image

.single-image {
  background-image: url("logo.png");
  background-repeat-x: no-repeat;
  background-repeat-y: no-repeat;
  background-position: center;
}

With repetition disabled on both axes, the image appears once at the center of the positioning area.

Positioning a Single Row

.bottom-row {
  background-image: url("pattern.png");
  background-size: 30px 30px;
  background-repeat-x: repeat;
  background-repeat-y: no-repeat;
  background-position-y: bottom;
}

The image repeats horizontally along the bottom of the element without creating additional vertical rows.

Use no-repeat when vertical duplication is unnecessary or when only horizontal repetition is desired.

The space Value

The space value repeats complete background tiles vertically and distributes the remaining height evenly between them.

.spaced-pattern {
  background-image: url("pattern.png");
  background-size: 40px 40px;
  background-repeat-x: no-repeat;
  background-repeat-y: space;
}

When at least two tiles fit, the first and last tiles align with the top and bottom edges of the positioning area, and equal gaps appear between the tiles.

Calculating Vertical Spacing

Suppose the background positioning area is 250 pixels tall and each tile is 40 pixels tall.

Six complete tiles occupy 240 pixels. The remaining 10 pixels are distributed across five gaps, creating 2-pixel spaces between adjacent tiles.

When Only One Tile Fits

If only one complete tile fits vertically, the image is displayed once along that axis. Its vertical position is determined by background-position-y.

Preserving Tile Height

The space value does not resize the tiles. It changes only the spacing between them.

This is useful for decorative icons, markers, and repeated graphics that should retain their original dimensions as an element changes height.

Spacing with Horizontal Repetition

.spaced-rows {
  background-image: url("pattern.png");
  background-size: 40px 40px;
  background-repeat-x: repeat;
  background-repeat-y: space;
}

The image repeats continuously across each row while complete rows are distributed vertically with equal spacing.

The round Value

The round value adjusts the heights of repeated background tiles so a whole number fits within the background positioning area.

.rounded-pattern {
  background-image: url("pattern.png");
  background-size: 45px 45px;
  background-repeat-x: no-repeat;
  background-repeat-y: round;
}

The browser determines an appropriate number of tiles and adjusts their heights to fill the available vertical space without gaps or clipped edge tiles.

How Tile Resizing Works

Consider a 250-pixel-tall positioning area with tiles initially specified as 45 pixels tall.

The browser selects six tiles and adjusts each tile to approximately 41.67 pixels tall, allowing them to fill the 250-pixel height.

Preserving Image Aspect Ratio

If the background width is auto and horizontal repetition is not round, the browser can adjust the automatic width to preserve the image's intrinsic aspect ratio.

.proportional-pattern {
  background-image: url("pattern.png");
  background-size: auto 45px;
  background-repeat-x: no-repeat;
  background-repeat-y: round;
}

When both axes use round, the browser can adjust the dimensions independently, potentially changing the image's proportions.

Comparing space and round

Value Vertical Tile Size Remaining Space
space Preserved Distributed between tiles
round Adjusted to fit No extra gaps between tiles

Use round when filling the available height with complete tiles is more important than preserving the exact original tile height.

Working with background-repeat-x

The background-repeat-x and background-repeat-y properties control horizontal and vertical repetition independently.

Repeating Only Vertically

.vertical-only {
  background-repeat-x: no-repeat;
  background-repeat-y: repeat;
}

This produces a vertical column of repeated images.

Repeating Only Horizontally

.horizontal-only {
  background-repeat-x: repeat;
  background-repeat-y: no-repeat;
}

This produces a horizontal row of repeated images.

Using Different Styles on Each Axis

.mixed-repetition {
  background-repeat-x: space;
  background-repeat-y: round;
}

Tiles are distributed horizontally with equal spacing while their heights are adjusted to fit vertically.

Equivalent Shorthand Values

Horizontal Vertical background-repeat Equivalent
no-repeat repeat repeat-y
repeat no-repeat repeat-x
repeat repeat repeat
no-repeat no-repeat no-repeat
space round space round

The longhand properties are useful when only one axis needs to change without replacing the other axis's repetition settings.

Working with background-position

The background-position property determines the initial placement of the background image before the repetition pattern is applied.

Positioning a Vertical Column

.right-strip {
  background-image: url("stripe.png");
  background-repeat-x: no-repeat;
  background-repeat-y: repeat;
  background-position: right top;
}

The image repeats vertically along the right edge of the positioning area.

Positioning a Horizontal Row

.bottom-strip {
  background-image: url("stripe.png");
  background-repeat-x: repeat;
  background-repeat-y: no-repeat;
  background-position: left bottom;
}

The image repeats horizontally along the bottom edge.

Positioning a Single Image

.centered-decoration {
  background-image: url("decoration.png");
  background-repeat-x: no-repeat;
  background-repeat-y: no-repeat;
  background-position: center;
}

The image is centered and displayed once.

Positioning with space and round

When multiple tiles fit vertically using space, the spacing rules determine their vertical placement rather than background-position-y.

With round, the resized tiles fill the vertical positioning area, so changing their vertical position generally has no visible effect.

Vertical positioning remains useful when repetition is disabled or when only one tile fits using space.

Working with background-size

The background-size property determines the dimensions of each background image tile before repetition is applied.

Using Small Tiles

.small-tiles {
  background-image: url("pattern.png");
  background-size: 25px 25px;
  background-repeat-x: no-repeat;
  background-repeat-y: repeat;
}

Smaller tiles produce more vertical repetitions within the same height.

Using Large Tiles

.large-tiles {
  background-image: url("pattern.png");
  background-size: 80px 80px;
  background-repeat-x: no-repeat;
  background-repeat-y: repeat;
}

Larger tiles produce fewer vertical repetitions.

Combining Size and Spacing

.spaced-icons {
  background-image: url("icon.png");
  background-size: 40px 40px;
  background-repeat-x: no-repeat;
  background-repeat-y: space;
}

The tiles retain their specified height while the browser distributes the remaining vertical space between them.

Combining Size and Rounding

.fitted-pattern {
  background-image: url("pattern.png");
  background-size: 45px 45px;
  background-repeat-x: no-repeat;
  background-repeat-y: round;
}

The browser may adjust the specified 45-pixel tile height to fit a complete number of tiles within the positioning area.

Background image dimensions are especially important when using space and round, because the tile height determines how many repetitions fit.

Background Positioning and Clipping

The background-origin and background-clip properties affect the area used for positioning and painting repeated background images.

The background-origin Property

By default, background images are positioned relative to the padding box. The background-origin property can change the positioning area to the border box or content box.

.content-pattern {
  padding: 20px;
  background-image: url("pattern.png");
  background-origin: content-box;
  background-repeat-x: no-repeat;
  background-repeat-y: space;
}

The vertical spacing is calculated using the content box as the background positioning area.

The background-clip Property

The background-clip property controls where the background is painted. Repeated tiles may extend beyond the positioning area but are clipped at the painting boundary.

.clipped-pattern {
  padding: 20px;
  border: 5px solid #1769aa;
  background-image: url("pattern.png");
  background-origin: padding-box;
  background-clip: content-box;
  background-repeat-x: no-repeat;
  background-repeat-y: repeat;
}

The image repeats vertically relative to the padding box, but only the portions within the content box are visible.

Remember that the positioning area and painting area can be different, which may affect the appearance of repeated tiles near the edges.

Multiple Background Layers

The background-repeat-y property accepts comma-separated values for controlling vertical repetition on multiple background image layers.

.layered-panel {
  background-image: url("logo.png"), url("pattern.png");
  background-repeat-x: no-repeat, repeat;
  background-repeat-y: no-repeat, repeat;
  background-position: center, left top;
}

The first image appears once in the center. The second image repeats in both directions behind it.

Different Vertical Repetition Styles

.three-layers {
  background-image: url("icon.png"), url("stripe.png"), url("texture.png");
  background-repeat-x: no-repeat, no-repeat, repeat;
  background-repeat-y: no-repeat, space, round;
  background-position: center, left top, left top;
}

The first image appears once, the second is distributed vertically with spacing, and the third is resized vertically to fit complete tiles.

Matching Values to Layers

Each vertical repetition value corresponds to the background image at the same position in the comma-separated list.

If fewer values are specified than background image layers, the browser repeats the list as necessary. Extra values are not used when there are fewer image layers.

Background Layer Order

The first background image is painted above subsequent image layers. The background color is painted beneath all background images.

Different vertical repetition settings can be combined to create decorative columns, repeating patterns, and layered backgrounds.

Shorthand Properties and Resets

The background-repeat-y property is the vertical longhand component of background-repeat.

.vertical-strip {
  background-repeat-x: no-repeat;
  background-repeat-y: repeat;
}

This is equivalent to:

.vertical-strip {
  background-repeat: repeat-y;
}

Changing Only Vertical Repetition

.panel {
  background-repeat: no-repeat;
  background-repeat-y: repeat;
}

The final declaration enables vertical repetition while leaving horizontal repetition disabled.

Shorthand Override Behavior

.panel {
  background-repeat-y: space;
  background-repeat: repeat;
}

The later background-repeat shorthand sets both axes to repeat, replacing the earlier vertical space setting.

Using the background Shorthand

.panel {
  background-repeat-y: no-repeat;
  background: url("pattern.png");
}

The final background shorthand resets horizontal and vertical repetition to their initial value of repeat.

To preserve a vertical repetition setting, place the longhand declaration after the shorthand.

.panel {
  background: url("pattern.png") no-repeat;
  background-repeat-y: repeat;
}

This produces vertical repetition while keeping horizontal repetition disabled.

A Compatibility-Friendly Alternative

.panel {
  background-image: url("pattern.png");
  background-repeat: no-repeat space;
}

The two-value background-repeat syntax expresses the same horizontal and vertical behavior without requiring the separate longhand properties.

background-repeat-y Example

The following example compares four vertical repetition styles: repeat, no-repeat, space, and round.

Each panel uses the same circular gradient image. Horizontal repetition is disabled so the differences in vertical tiling are easy to see.

<div class="background-repeat-y-demo">
  <div class="repeat-box repeat">repeat</div>
  <div class="repeat-box no-repeat">no-repeat</div>
  <div class="repeat-box space">space</div>
  <div class="repeat-box round">round</div>
</div>
.background-repeat-y-demo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
}
.background-repeat-y-demo .repeat-box {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 240px;
  padding: 12px;
  box-sizing: border-box;
  border: 2px solid #1769aa;
  border-radius: 6px;
  background-color: #e8f2fb;
  background-image: radial-gradient(circle, #1769aa 0 60%, #69b7e8 62% 75%, transparent 77%);
  background-size: 48px 48px;
  background-position: left top;
  background-repeat-x: no-repeat;
  color: #173b5e;
  font-weight: bold;
  text-align: center;
}
.background-repeat-y-demo .repeat {
  background-repeat-y: repeat;
}
.background-repeat-y-demo .no-repeat {
  background-repeat-y: no-repeat;
}
.background-repeat-y-demo .space {
  background-repeat-y: space;
}
.background-repeat-y-demo .round {
  background-repeat-y: round;
}

The browser result includes equivalent background-repeat declarations as fallbacks for browsers without support for the separate vertical longhand.

Browser Result
repeat
no-repeat
space
round

The repeat panel displays a continuous column of tiles, while no-repeat displays one tile.

The space panel distributes complete tiles with equal vertical gaps, and the round panel adjusts tile heights to fill the available space.

All four panels disable horizontal repetition, so the demonstration shows one column rather than multiple columns of tiles.

Important Considerations

Keep the following points in mind when using background-repeat-y:

  • Default value: The initial value is repeat.
  • Vertical repetition: The property controls only repetition along the vertical axis.
  • Horizontal repetition: Use background-repeat-x to control repetition along the horizontal axis.
  • Continuous tiling: The repeat value allows partial tiles at the edges of the painting area.
  • Single vertical tile: The no-repeat value prevents additional vertical copies but does not disable horizontal repetition.
  • Tile spacing: The space value preserves tile heights and distributes remaining space between complete tiles.
  • Tile resizing: The round value adjusts tile heights to fit an integer number of repetitions.
  • Background size: The rendered image height affects how many vertical tiles fit.
  • Background position: Vertical positioning affects non-repeating tiles and the alignment of repeated patterns.
  • Background origin: The positioning area is determined by background-origin and defaults to the padding box.
  • Background clipping: Repeated tiles may be clipped at the background painting boundary.
  • Multiple layers: Comma-separated values can assign different vertical repetition styles to individual background images.
  • Gradients: CSS gradients are background images and can be repeated vertically.
  • Shorthand resets: Later background-repeat and background shorthand declarations can override the vertical repetition setting.
  • Compatibility: Use the two-value background-repeat shorthand as a fallback for browsers without support for the separate longhand.
  • Accessibility: Avoid detailed repeating patterns behind text when they reduce contrast or readability.

Use background-repeat-y when vertical background repetition needs to change independently of horizontal repetition.

Browser Support

The background-repeat-y property has more limited compatibility than the established background-repeat shorthand. Support for the separate vertical and horizontal longhands varies by browser version.

For broader compatibility, use background-repeat with two values to specify horizontal and vertical repetition independently.

Providing a Fallback

.vertical-pattern {
  background-image: url("pattern.png");
  background-repeat: no-repeat space;
  background-repeat-y: space;
}

The first declaration establishes vertical spacing with no horizontal repetition. Browsers that support background-repeat-y can apply the second declaration without changing the horizontal setting.

Using Feature Detection

.vertical-pattern {
  background-repeat: repeat-y;
}
@supports (background-repeat-y: space) {
  .vertical-pattern {
    background-repeat-y: space;
  }
}

The feature query applies vertical spacing only when the browser recognizes the separate property and value.

Visit Can I Use? to check current browser compatibility before relying on this property in production.

Specifications

The background-repeat-y property is defined as a longhand component of background repetition in the CSS Backgrounds and Borders Module Level 4 specification. The related background-repeat shorthand is defined in Level 3.

CSS Backgrounds and Borders Module Level 4

CSS Backgrounds and Borders Module Level 3