From 94b0178d1ab72b178eedee5d40ae9a567a1412eb Mon Sep 17 00:00:00 2001 From: CaptainTech205 <9319730+CaptainTech205@users.noreply.github.com> Date: Fri, 6 Feb 2026 18:20:35 +0100 Subject: [PATCH 1/4] First version of this markdown --- .../background-position-x.md | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 content/css/concepts/background/terms/background-position-x/background-position-x.md diff --git a/content/css/concepts/background/terms/background-position-x/background-position-x.md b/content/css/concepts/background/terms/background-position-x/background-position-x.md new file mode 100644 index 00000000000..6569ad2f91c --- /dev/null +++ b/content/css/concepts/background/terms/background-position-x/background-position-x.md @@ -0,0 +1,62 @@ +--- +Title: CSS background-position-x +Description: Sets the inital horizontal position of a background image. +Subjects: + - CSS + - Web design + - Web Development +Tags: + - Layout + - Background + - HTML +CatalogContent: + - Learn CSS + - UX Designer + - Learn Intermediate CSS + - Front-End Engineer + - Full-Stack Engineer +--- +The CSS **background-position-x** property sets the initial horizontal position (the x axis) of a background image. This position is defined relative to the coordinate system established by the [background-origin](https://www.codecademy.com/resources/docs/css/background/background-origin) property. + +Note that the value of background-position-x is overridden by any subsequent declarations of the background or [background-position](https://www.codecademy.com/resources/docs/css/background/background-position) shorthand properties. By default, a background image is placed at the top-left corner of an element and repeated both vertically and horizontally. + +## Syntax +```css +/* Keyword values */ +background-position-x: left; +background-position-x: right; +background-position-x: center; + +/* Length and percentage values */ +background-position-x: 64px; +background-position-x: 25%; +background-position-x: 5em; +background-position-x: 1cm; + +/* Global values */ +background-position-x: inherit; +background-position-x: initial; +background-position-x: revert; +background-position-x: revert-layer; +background-position-x: unset; +``` + +## Example +In the following example we use the HTML div tag to set the background image with CSS. + +### HTML +```html +
)%8fq3LCvN*;36QawKXucBxAuc6(>sAx*;)Wz|C| z>Y+zWd$+$SyOsNp$hjCf@&tx{^l6}^ipgGuuaSt1@|P!pT=MESsgj1Z-H~K-%6)JG z(0@Vcx@qQ~`JKet&_`v#^Z<)A7dYiNrDfth`bAI2I`QhVz+Mb%DhX^1cySAAY$}fo zlepU-I_5d>faPuL*@E7nCCL2BwJRP{#?mYrq7$&c)G+AZMVbmLDDD6qKN|1YI!t#L zuT^*E=a;!qm+H=qYvi!N82(hJV3qfa++&HzLK@g~V4Xj~etqGt(PbDvk>tydii4WR zML#;8+uw?O@uA=wN+u_Bc-z4K7^ $BU2|PA7mbVSGdT(@eH0rG!?EgfKZ@g6gc `19+#t{m8D WjCnqCxe0i}f#9wlhiT3yFaHC++gnWl literal 0 HcmV?d00001 From cefc1280c432ea0a855c8cf2ea15344a9b8942b4 Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Tue, 24 Feb 2026 13:21:36 +0530 Subject: [PATCH 3/4] Revise background-position-x documentation Updated the documentation for the background-position-x property, including changes to the title, description, parameters, and examples. --- .../background-position-x.md | 73 +++++++++++-------- 1 file changed, 44 insertions(+), 29 deletions(-) diff --git a/content/css/concepts/background/terms/background-position-x/background-position-x.md b/content/css/concepts/background/terms/background-position-x/background-position-x.md index 4bb2a25cf72..c40e302c465 100644 --- a/content/css/concepts/background/terms/background-position-x/background-position-x.md +++ b/content/css/concepts/background/terms/background-position-x/background-position-x.md @@ -1,54 +1,69 @@ --- -Title: CSS background-position-x -Description: Sets the inital horizontal position of a background image. +Title: 'background-position-x' +Description: 'Sets the horizontal position of a background image.' Subjects: - - 'Web Design' - - 'Web Development' + - 'Web Design' + - 'Web Development' Tags: - - 'CSS' - - 'Background' - - 'Positioning' - - 'Properties' - - 'Layout' + - 'CSS' + - 'Background' + - 'Layout' + - 'Positioning' + - 'Properties' CatalogContent: - - 'learn-css' - - 'paths/front-end-engineer-career-path' + - 'learn-css' + - 'paths/front-end-engineer-career-path' --- -The CSS **background-position-x** property sets the initial horizontal position (the x axis) of a background image. This position is defined relative to the coordinate system established by the [background-origin](https://www.codecademy.com/resources/docs/css/background/background-origin) property. -Note that the value of background-position-x is overridden by any subsequent declarations of the background or [background-position](https://www.codecademy.com/resources/docs/css/background/background-position) shorthand properties. By default, a background image is placed at the top-left corner of an element and repeated both vertically and horizontally. +The CSS background-position-x property sets the horizontal (x-axis) position of a background image. The position is calculated relative to the box defined by the [`background-origin`](https://www.codecademy.com/resources/docs/css/background/background-origin) property. + +If the `background` or [`background-position`](https://www.codecademy.com/resources/docs/css/background/background-position) shorthand properties are declared after `background-position-x`, their values override it. + +By default, a background image is positioned at the top-left corner of an element and repeated both horizontally and vertically. ## Syntax + ```pseudo background-position-x: value; ``` -### Parameters -Value can be one of the following: -- Position keyword: `left`, `right`, `center` -- Length and percentage values: `64px`, `5em`, `1cm`, `25%` -- Global values: `inherit`, `initial`, `revert`, `revert-layer`, `unset` +**Parameters:** + +- `value` can be one of the following: + + - **Position keywords:** `left`, `center`, `right` + - **Length values:** `10px`, `2em`, `1cm` + - **Percentage values:** `25%` + - **Keyword and offset combinations:** `left 20px`, `right 10%` + - **Comma-separated values (for multiple background layers):** `left`, `right` + - **Global values:** `inherit`, `initial`, `revert`, `revert-layer`, `unset` + +When multiple background images are used, values are applied in order, separated by commas. ## Example -In the following example we use the HTML div tag to set the background image with CSS. -### HTML +In this example, a `div` element is styled with a centered background image using `background-position-x`: + +The HTML code is: + ```html ``` -### CSS +The CSS code is: + ```css div { - width: 300px; - height: 300px; - background-color: grey; - background-image: url("../../../../../../media/cc_logo.png"); - background-repeat: no-repeat; - background-position-x: center; + width: 300px; + height: 300px; + background-color: grey; + background-image: url("../../../../../../media/cc_logo.png"); + background-repeat: no-repeat; + background-position-x: center; } ``` -### Result - \ No newline at end of file +The output of this code is: + + From dadabc2c267339f60b29ecb63c15440d281defb5 Mon Sep 17 00:00:00 2001 From: Mamta WardhaniDate: Tue, 24 Feb 2026 13:22:06 +0530 Subject: [PATCH 4/4] Enhance background-position-x property description Updated the description of the background-position-x property to emphasize its formatting. --- .../terms/background-position-x/background-position-x.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/css/concepts/background/terms/background-position-x/background-position-x.md b/content/css/concepts/background/terms/background-position-x/background-position-x.md index c40e302c465..8493e78dfbd 100644 --- a/content/css/concepts/background/terms/background-position-x/background-position-x.md +++ b/content/css/concepts/background/terms/background-position-x/background-position-x.md @@ -15,7 +15,7 @@ CatalogContent: - 'paths/front-end-engineer-career-path' --- -The CSS background-position-x property sets the horizontal (x-axis) position of a background image. The position is calculated relative to the box defined by the [`background-origin`](https://www.codecademy.com/resources/docs/css/background/background-origin) property. +The CSS **`background-position-x`** property sets the horizontal (x-axis) position of a background image. The position is calculated relative to the box defined by the [`background-origin`](https://www.codecademy.com/resources/docs/css/background/background-origin) property. If the `background` or [`background-position`](https://www.codecademy.com/resources/docs/css/background/background-position) shorthand properties are declared after `background-position-x`, their values override it.