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).
Normal flow and the position property (8.3.1)
| Value | What happens |
|---|---|
| static (default) | **Normal flow**: block boxes stack down the page, inline boxes flow along lines |
| relative | The box keeps its space in the flow but is drawn offset by top, right, bottom or left from where it would have been |
| absolute | The 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 |
| fixed | Taken 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) |
| sticky | Behaves 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;
}- Positioned elements can overlap. z-index sets the stacking order: a higher z-index is drawn on top (it works on positioned elements).
- float: left or right moves a box to that side and lets text and inline content wrap round it, as in a magazine. clear: both makes an element start below any floats.
Box model properties (8.3.2)
- display sets the box type: block, inline, inline-block (sits in a line but accepts width, height and vertical margins), none (removed from the page entirely), flex and grid (layouts in the next lesson).
display: noneremoves the element and its space;visibility: hiddenhides it but keeps its space. - width and height, with max-width and min-width (for example max-width: 100% stops an image overflowing its container).
- border, margin and padding, with individual sides such as margin-left.
margin: 0 auto;centres a block that has a set width horizontally.
.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.
- Staying put while scrolling needs position: fixed (relative to the window).
- Place it with bottom: 20px and right: 20px.
- Use z-index to keep it above other positioned content.
Answer: ```css #topBtn { position: fixed; bottom: 20px; right: 20px; z-index: 10; } ```
Check yourself
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
Sources
- Pearson Edexcel International Advanced Subsidiary/Advanced Level in Information Technology specification (first teaching 2018), Unit 2 Topics 7 to 11
- Pearson qualifications: Edexcel International Advanced Level Information Technology (2018)
Last updated 8 November 2026. Spotted a mistake? Tell us.