HTML: The 'aria-current' attribute does not have a valid value

I’ve uploaded my site and checked it using Total Validator. It comes back with the following warning:

HTML: The ‘aria-current’ attribute does not have a valid value

This is my nav:

<nav>
	<ul>
		<?php foreach ($site->children()->listed() as $item): ?>
		<li><a <?php e($item->isOpen(), ' aria-current') ?> href="<?= $item->url() ?>"><?= $item->title() ?></a></li>
		<?php endforeach ?>
	</ul>
</nav>

And this is the generated source code (for example the About page):

	<nav>
		<ul>
						<li><a  aria-current href="https://www.example.co.uk/about">About</a></li>
						<li><a  href="https://www.example.co.uk/portfolio">Portfolio</a></li>
						<li><a  href="https://www.example.co.uk/services">Services</a></li>
						<li><a  href="https://www.example.co.uk/ethical-design">Ethics</a></li>
						<li><a  href="https://www.example.co.uk/contact">Contact</a></li>
					</ul>
	</nav>

But I’m getting the warning message. Any ideas why?

See example by mdn web docs for aria-current usage:

<a href="https://www.example.co.uk/about" aria-current="page">

The code for my nav bar is based on the Kirby Starter Kit:

<?php foreach ($site->children()->listed() as $item): ?>
<a <?php e($item->isOpen(), 'aria-current ') ?> href="<?= $item->url() ?>"><?= $item->title()->esc() ?></a>
<?php endforeach ?>

This is adding aria-current to the current page in my nav bar, but it is not adding aria-current="page" Should it?

From the document @Manuel pointed you to:

The aria-current attribute accepts a limited list of values including page, step, location, date, time, true, and false. Any non-null string value not included in this list of enumerated values is treated as if aria-current="true" were set, not the default false value. If the attribute is not present, is an empty string, is present with no value, or is set to aria-current="false" it is not exposed to the user.

Am I correct in saying that the source code should be aria-current="page"?

I’m using the code from the Kirby Starter Kit for my nav bar. But it is simply adding aria-current with no value. Which is coming up as an error when validating the site. So is this a problem with the Kirby Starter Kit code?

Yes, I think that needs a fix.

Any ideas when this will be fixed, or even better what the fixed code will be, so that I can use it now? Many thanks

You can fix the code easily like so:

<?php e($item->isOpen(), 'aria-current="page" ') ?>
1 Like

Yay. Brilliant thank you!!!