All subjects · Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript

CSS positioning: normal flow, relative, absolute, fixed, float and display

Edexcel IAL Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript

Positioning controls where boxes go: in the normal flow, offset, taken out of the flow, fixed to the window or floated, and the box model properties control their size and display (spec 8.3.1 and 8.3.2).

Practise this in the app: instant marking and a fix for every mistake. Free, no email needed to start.

Practise this lesson

Normal flow and the position property (8.3.1)

ValueWhat happens
static (default)**Normal flow**: block boxes stack down the page, inline boxes flow along lines
relativeThe box keeps its space in the flow but is drawn offset by top, right, bottom or left from where it would have been
absoluteThe box is **taken out of the flow** (other content closes up) and placed relative to its nearest positioned ancestor (one with position other than static), or to the page if there is none
fixedTaken out of the flow and placed relative to the **browser window**: it stays put when the page scrolls (fixed menus, cookie banners, back-to-top buttons)
stickyBehaves as relative until scrolling reaches a set offset, then sticks like fixed

Overlapping and floating

.card {
  position: relative;
}
.card .badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
}
.sidebar-img {
  float: left;
  width: 40%;
  margin-right: 15px;
}
footer {
  clear: both;
}

Box model properties (8.3.2)

.container {
  width: 80%;
  max-width: 1100px;
  margin: 0 auto;
}
nav li {
  display: inline-block;
  padding: 10px 15px;
}

Worked example

A 'Back to top' button must stay in the bottom right corner of the window, 20 pixels from each edge, while the page scrolls, and appear above other content. Write the CSS.

  1. Staying put while scrolling needs position: fixed (relative to the window).
  2. Place it with bottom: 20px and right: 20px.
  3. Use z-index to keep it above other positioned content.

Answer: ```css #topBtn { position: fixed; bottom: 20px; right: 20px; z-index: 10; } ```

Key idea: static is normal flow; relative offsets but keeps its space; absolute leaves the flow and is placed against the nearest positioned ancestor; fixed is placed against the window; float wraps text round a box; z-index orders overlaps; display: none removes, margin: 0 auto centres.

Check yourself

  1. Which position value keeps a navigation bar at the top of the window while the page scrolls?
    • relative
    • static
    • fixed
    • absolute inside a static parent
    Show answer

    fixed. fixed positions relative to the viewport, so it does not move on scrolling.

  2. An element has position: absolute; top: 0; right: 0. Its parent has position: relative. Where does it appear?
    • In the top right corner of the parent
    • In the top right corner of the browser window, even when scrolling
    • Where it would normally be in the flow
    • In the top left corner of the page
    Show answer

    In the top right corner of the parent. An absolute element is placed against its nearest positioned ancestor, the relative parent.

  3. What happens to the space an element took up when it is given position: relative; left: 30px?
    • The space closes up and the element moves 30px left
    • The element is removed from the page
    • The space is kept and the element is drawn 30px to the right
    • The element sticks to the window
    Show answer

    The space is kept and the element is drawn 30px to the right. Relative positioning offsets the drawing but keeps the original space. left: 30px pushes it 30px from the left, so it moves right.

  4. Which declaration makes text wrap round the right-hand side of an image?
    • float: right;
    • float: left;
    • position: fixed;
    • clear: both;
    Show answer

    float: left;. Floating the image left puts it on the left so the text flows down its right-hand side.

  5. Which CSS property decides which of two overlapping positioned elements is drawn on top? Type the property name.
    Show answer

    z-index. The higher z-index is drawn in front.

  6. What is the difference between display: none and visibility: hidden?
    • display: none keeps the space; visibility: hidden removes it
    • display: none removes the element and its space; visibility: hidden hides it but keeps its space
    • There is no difference
    • visibility: hidden deletes the element from the HTML
    Show answer

    display: none removes the element and its space; visibility: hidden hides it but keeps its space. display: none takes the element out of the layout entirely.

  7. A div has width: 800px. Which declaration centres it horizontally in the page?
    • text-align: center;
    • float: center;
    • position: center;
    • margin: 0 auto;
    Show answer

    margin: 0 auto;. Automatic left and right margins share the spare space equally. text-align centres inline content inside it, not the box itself.

  8. Menu items must sit side by side but also accept padding and a fixed width. Which display value suits them?
    • inline
    • none
    • inline-block
    • table-caption
    Show answer

    inline-block. inline-block flows in a line like inline but accepts width, height and vertical padding and margins.

Practise with instant feedback

Sources

Last updated 8 November 2026. Spotted a mistake? Tell us.