πŸš€ LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Expert Masterclasses.
πŸŽ“ COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEcss

css Documentation

LOADING ENGINE...

CSS background-position

Control the placement of background images with precision.

style.css
.container {
background-image: url('img.jpg');
background-position: center;
}
style.css
1 / 8
πŸ—ΊοΈ

Tutor:The CSS `background-position` property sets the starting position of a background image. By default, an image is placed at the top-left corner (0% 0%).


CSS Positioning Mastery

Unlock nodes by learning background coordinates and keywords.

Concept 1: Keywords

The easiest way to move a background image is using keywords like top, bottom, left, right, and center.

System Check

Which value centers the image horizontally and vertically?


Community Holo-Net

Share Layouts

Created a cool background composition? Share your CSS snippets.

Enjoying this guide?

Codesyllabus is 100% free and open-source. Support our mission, pay for server infrastructure, and fuel new tutorials by buying us a coffee!

CSS Background Position

Author

Pascual Vila

Frontend Instructor.

The background-position CSS property sets the initial position for each background image. The position is relative to the positioning layer set by background-origin.

Coordinate System

The first value represents the horizontal position (x-axis), and the second value represents the vertical position (y-axis). If only one value is specified, the second value defaults to center.

Values and Units

  • Keywords: top, bottom, left, right, center.
  • Percentages: 0% to 100%. aligns the percent point of the image to the percent point of the container.
  • Lengths: px, em, rem, etc. Exact offsets from the top-left corner.

The Percentage Quirk

Unlike other CSS properties where percentage refers strictly to the container size, background-position: 50% 50% means "Align the center (50%) of the image with the center (50%) of the container".

Best Practices

Use keywords for standard alignments like centering. Use percentages for fluid layouts where the relationship between image and container matters. Use pixels for precise, fixed designs.

Positioning Glossary

background-position
CSS property defining the starting position of a background image.
Keywords
Named locations: top, right, bottom, left, center.
Length Units
Fixed values like px or relative values like em that define an exact offset from the origin.
X / Y Axis
X is the horizontal axis (Left/Right). Y is the vertical axis (Top/Bottom).