Menu
CoddyTech

Current Page Cues

Part of the Responsive UI Patterns section of Coddy's Tailwind CSS journey. Lesson 7 of 55.

Current-page styling is more useful when it follows semantic state. aria-current="page" tells readers which link represents the current page. The named variant current: applies a utility only while that exact attribute value is present.

<a href="#catalog" aria-current="page" class="font-normal current:font-semibold">Catalog</a>

In the library example, the current link becomes semibold. Removing or moving the attribute moves the visual cue without changing the class list. Use a second cue such as an underline so current navigation is not distinguished by color alone.

In styles.css, define @custom-variant current (&[aria-current=page]); to name this attribute selector. CSS does not discover the active route. The supplied behavior updates attributes; your utilities present that state. Keep inactive base styles explicit so switching away restores the intended appearance.

challenge icon

Challenge

Medium

Make only the current schedule link bold and underlined. Other links must use normal weight and no decoration. The supplied switch changes which link has aria-current="page"; styling must follow it in both directions.

Preserve the supplied content, semantic elements and IDs. Edit the requested utility classes. Press Run preview after edits, then Check/Run code to grade the result. Supplied JavaScript is read-only.

Try it yourself

<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Interface workshop</title><link rel="stylesheet" href="./styles.css"></head><body>
<nav aria-label="Schedule"><a id="day" href="#day" aria-current="page" class="font-normal no-underline">Day</a> <a id="week" href="#week" class="font-normal no-underline">Week</a></nav><button id="switch">Switch current view</button>
<script src="./controls.js"></script>
</body></html>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Responsive UI Patterns