# Fixed

Fixed positioning places an element relative to the browser window, so it stays on screen while the page scrolls.

Apprentice · CSS · Updated October 29, 2026

## After this lesson you can

- Keep an element in the same spot on screen while the page scrolls with fixed positioning

## Key takeaways

- Fixed positioning places an element relative to the browser window, measured from the window's top left corner.
- A fixed element stays in the same spot on screen while the rest of the page scrolls.
- The space it would have used isn't kept, so the elements after it move up into that space.

`fixed` position places an element relative to the browser window (the viewport), measured from its top left corner, so it stays in the same spot on screen while the page scrolls. The space it would have used is not kept.

```css
.div-2 {
    position: fixed;
    left: 30px;
    top: 30px;
}
```

![Div 2 placed 30px from the window's top left corner, over div 1, and div 3 moved up into the space div 2 left](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/09/f14f4087e4d94d16a4db232630e505fb.png "Div 2 uses position: fixed")

As the page is scrolled, fixed divs do not scroll.

![After scrolling, div 2 is still 30px from the top of the window while divs 3, 4 and 5 scroll up underneath it](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/09/b3765343670a44b6ba2bcd1a64b4cd49.png "Div 2 does not scroll")

## Check yourself

2 questions to try on the lesson page.

## So what

Chat buttons, cookie notices and navigation bars that never leave the screen are fixed elements.

## Key terms

- [Fixed positioning](https://www.ask-codey.com/glossary/fixed-positioning)

Source: https://www.ask-codey.com/lessons/css-position-fixed
