Sub topic 7
Position: where an element sits shapes its priority
Size and contrast work on an element's own appearance. Position works on its location. Two identical buttons in different places on a page will not get the same attention, because readers do not look at a page evenly. This chapter covers how placement sets priority and how to use it deliberately.
This chapter assumes you know basic HTML structure, CSS selectors and custom properties, the box model, and how CSS Grid and Flexbox lay out a page. It also assumes you have read the chapters on size and contrast, since position is only one of three cues.
Why position carries priority
Readers do not read a page top to bottom, word by word. They scan. Where their eyes land first depends on habits formed by reading, on the layout, and on what the page looks like at a glance. Three effects follow from this:
- Start edge first. In left-to-right languages, people begin at the top-left. In right-to-left languages such as Arabic and Hebrew, they begin at the top-right. The place where reading starts is the inline-start edge.
- Earlier means more important. Readers assume that what comes first matters most. A heading at the top of a column reads as the column's subject. The same text at the bottom reads as a footnote.
- Isolation gets noticed. An element with open space around it stands out, even if it sits in a weak position. Spacing is covered in the next chapter, but keep it in mind here.
Position is also a signal of role. Readers expect a logo at the start of the header, navigation near the top, and legal links at the bottom. Putting an element where users expect its type is a form of hierarchy too, because it lets them find it without searching.
Scanning patterns as a starting map
The previous chapter described how people scan. Here is a short recap, with the design decision each pattern suggests.
| Pattern | Typical page | Where attention goes | Placement decision |
|---|---|---|---|
| F-pattern | Text-heavy pages, articles, search results | Across the top, then down the start edge with shorter sweeps | Put the key term at the start of each heading and paragraph. Keep important labels on the start edge. |
| Z-pattern | Sparse pages such as landing pages | Top-start, across to top-end, diagonally down, then across the bottom | Logo at top-start, main action at top-end or the lower end of the diagonal, call to action at the bottom-end. |
| Layer-cake | Pages with clear headings | Eyes jump from heading to heading | Make each heading informative, since readers use them to decide where to stop. |
These are tendencies observed in eye-tracking studies, not laws. Page content, task, and visual weight all change them. Use them to choose a first draft, then check the result with the tests in the last chapter of this tutorial.
Placement rules that hold up in practice
Put the primary element in the first view, near the start edge
The main heading and the main action of a page should be visible without scrolling on common screen sizes. This does not mean everything must be crammed above the fold. Studies show that people scroll readily when the page signals there is more. It means the reader should learn what this page is and what to do next from the first screen alone.
Place actions where the task ends
A primary action belongs where the reader finishes the thought it completes. For a form, that is below the last field, aligned with the fields. For an article, a related call to action fits at the end of the content. A "Subscribe" button in the header, far from the text that made the reader want to subscribe, wastes its position.
Order actions by priority, not by habit
When two buttons sit side by side, the one nearest the start edge is read first. Place the primary action at the inline-start of the group and the secondary one after it. Some platforms reverse this convention for dialogs, with the confirm button at the end. Whichever you choose, apply it consistently across the whole product, because readers learn the position.
Use placement for rank, not decoration
Centering everything gives no rank. If a headline, a paragraph, a button, and a footnote are all centered, position stops carrying information. Align related text to a common start edge, and reserve centering for short, single-focus blocks such as a hero statement.
Building it in CSS
Write position with logical properties, such as margin-inline, padding-block, and inline-size, and with Flexbox or Grid. These adapt to text direction, so the "start" edge stays the start edge in a right-to-left language. Physical properties like left and margin-left do not.
The page below places a logo at the inline-start, a nav at the inline-end, a headline and primary action first in the hero, and a lower-priority sidebar after the main content. Save it as an .html file and open it in a browser. Then add dir="rtl" to the <html> tag to see the layout mirror without any CSS changes.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Position demo</title>
<style>
body { margin: 0; font: 1rem/1.5 system-ui, sans-serif; color: #1a1a1a; }
.site-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem 2rem;
border-block-end: 1px solid #c8c8c8;
}
.site-header nav a { margin-inline-start: 1.5rem; color: #0b57d0; }
.page {
display: grid;
gap: 2rem;
max-inline-size: 64rem;
margin-inline: auto;
padding: 3rem 2rem;
}
@media (min-width: 48rem) {
.page { grid-template-columns: 2fr 1fr; }
}
h1 { margin: 0 0 0.5rem; font-size: clamp(1.75rem, 1.2rem + 2.5vw, 3rem); line-height: 1.15; }
.actions { display: flex; gap: 1rem; align-items: center; margin-block-start: 1.5rem; }
.button { padding: 0.6rem 1.2rem; border-radius: 4px; font: inherit; border: 2px solid #0b57d0; cursor: pointer; }
.button--primary { background: #0b57d0; color: #fff; font-weight: 700; }
.button--secondary { background: transparent; color: #0b57d0; }
.sidebar { font-size: 0.9rem; color: #444; }
</style>
</head>
<body>
<header class="site-header">
<strong>Acme</strong>
<nav>
<a href="#">Docs</a>
<a href="#">Pricing</a>
<a href="#">Sign in</a>
</nav>
</header>
<div class="page">
<main>
<h1>Ship your first site today</h1>
<p>Start with a template, change the text, and publish.</p>
<div class="actions">
<button class="button button--primary">Start free</button>
<button class="button button--secondary">See a demo</button>
</div>
</main>
<aside class="sidebar">
<p>Used by 4,000 teams. No credit card needed.</p>
</aside>
</div>
</body>
</html>Three placement choices in this code are worth naming:
- The primary button comes first in the DOM and in the flex row, so it sits at the inline-start of the actions.
- The sidebar is the second grid column on wide screens and falls after the main content on narrow screens. The less important content never jumps above the more important content.
margin-inline-starton the nav links, notmargin-left, keeps the spacing correct when the direction flips.
Position interacts with size and contrast
Position never acts alone. A small element at the top-start can lose to a large, high-contrast element in the middle. A strong position also lets you use weaker size or contrast. For example, a modest "Skip to content" link works as the first item in the page because of where it is, and a heading in the most visible position needs less size to dominate.
Use position to break ties. When two elements have similar size and contrast, readers rank the earlier and more start-aligned one higher. If your design needs the opposite ranking, change the position rather than adding a third emphasis cue.
Common errors
- Hiding the primary action in the end corner. A button pinned to the far end of a wide screen is far from the content and from the eye's entry point. Keep it near the content it acts on.
- Fixed or sticky elements that cover content. A sticky banner always occupies a high-priority spot. If it carries a low-priority message, it outranks your real content on every scroll position. Reserve sticky positions for navigation or a single key action.
- Using
position: absoluteorfloatto move things visually. It is easy to place something precisely and forget that other readers meet it in a different order. This is the visual-versus-source-order problem covered later in this tutorial. - Reordering with
orderorgrid-areawithout checking keyboard order. The Tab key follows the DOM, not the visual layout. A button that looks first but is reached fifth confuses keyboard users. - Copying a pattern without checking the content. An F-pattern layout that works for a news article may not fit a dashboard whose users look at a specific widget first.
- Assuming left means start. Physical
leftandrightbreak layouts for right-to-left languages. Use logical properties.
Position, grouping, and what comes next
Position decides the order in which separate elements are seen. It does not tell readers which elements belong together. Two buttons placed near each other may look related, but the placement alone does not make that clear. The next chapter covers spacing and proximity, which turn nearby elements into groups. After that, you will combine size, contrast, and position into one design, and then check that the DOM order agrees with what you see.
Summary of working rules
- Start reading at the inline-start edge, so put the page's subject there.
- Treat earlier as more important, and keep low-priority content later in the flow.
- Match placement to the user's task: actions go where the task ends.
- Order grouped actions with the primary one first, and apply the same rule everywhere.
- Use logical CSS properties and Grid or Flexbox so placement survives text-direction changes and narrow screens.
- Use position to break ties between elements of similar size and contrast.
Exercise
A checkout page has a "Pay now" button and a "Back to cart" link. A developer wrote the CSS .actions { display: flex; flex-direction: row-reverse; } so that "Pay now" appears at the visual start, but kept "Back to cart" first in the HTML. What problem does this cause, and how would you fix it?
Show answer
The visual order (Pay now, then Back to cart) no longer matches the DOM order (Back to cart, then Pay now). Keyboard users pressing Tab reach "Back to cart" first, and screen readers announce it first, so their sequence differs from what sighted users see. The fix is to put "Pay now" first in the HTML and remove row-reverse, so the DOM order and visual order agree. A regular flex-direction: row already places the first item at the inline-start edge, and it mirrors correctly in right-to-left languages.
Exercise
Why is margin-inline-start: 1.5rem a better choice than margin-left: 1.5rem for spacing between navigation links, and what happens to a layout built with left and right when the page is translated into Arabic?
Show answer
margin-inline-start refers to the start edge of the text direction, so it becomes the right margin in a right-to-left page without any extra CSS. margin-left always refers to the physical left side. In a layout built with left and right, the content flips direction but the spacing and alignment stay on the wrong sides, so the logo, navigation, and primary action no longer sit at the start and end edges readers expect. Logical properties keep the hierarchy intact.
Exercise
A landing page has a large, high-contrast headline in the middle, and a small gray "Get started" link at the top-start corner. A reader tells you they did not notice the link. Using the ideas in this chapter, give one placement change and one reason it helps.
Show answer
Move the main call to action to the end of the reader's sweep, directly below the headline and its supporting text, and place it first in a short row of actions. This helps because the headline already draws the first look, so an action placed right after it sits on the path the reader is following, and it is close to the content that motivates it. The corner position wins on order of reading but loses on weight, so position alone could not carry it.