Description
On WordPress 7.1 Beta 1, adding a Navigation block and setting a custom HTML Anchor causes the anchor value to be rendered on both the outer <nav> element and the inner <ul class="wp-block-navigation__container">, resulting in duplicate id attributes in the generated HTML.
IDs are expected to be unique within a document. Because the same anchor value is assigned to both elements, the generated markup is invalid HTML. This may affect CSS selectors, JavaScript lookups, HTML validation, and accessibility validation tools.
I expected the custom HTML Anchor to be applied only to the outer <nav> element. Instead, it is also applied to the inner navigation <ul>.
This issue is consistently reproducible with different anchor values and multiple Navigation block instances.
Step-by-step reproduction instructions
- Set up a fresh WordPress 7.1 Beta 1 site using a block theme.
- Add a Navigation block (core/navigation).
- Open Block Settings → Advanced → HTML Anchor and enter a custom ID (e.g.
header-navigation).
- Save and view the page on the frontend.
- Inspect the rendered HTML or View Source.
- Observe that the same ID is applied to both the outer
<nav> element and the inner <ul class="wp-block-navigation__container">.
- Repeat with a different anchor value and/or another Navigation block instance; the same duplication occurs.
Screenshots, screen recording, code snippet
Rendered HTML:
<nav class="is-responsive wp-block-navigation is-layout-flex wp-block-navigation-is-layout-flex"
id="header-navigation"
aria-label="Navigation">
...
<ul class="wp-block-navigation__container is-responsive wp-block-navigation"
id="header-navigation">
...
</ul>
</nav>
The custom HTML Anchor (header-navigation) is rendered on both the outer <nav> element and the inner navigation <ul>, resulting in duplicate IDs.
Browser console:
document.querySelectorAll('#header-navigation').length
// 2
Environment info
- WordPress version: 7.1 Beta 1
- Gutenberg version: Bundled with WordPress core (no standalone Gutenberg plugin installed)
- Active theme: Twenty Twenty-Four
- Browser: Chrome
- Operating System: Windows
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.
Description
On WordPress 7.1 Beta 1, adding a Navigation block and setting a custom HTML Anchor causes the anchor value to be rendered on both the outer
<nav>element and the inner<ul class="wp-block-navigation__container">, resulting in duplicateidattributes in the generated HTML.IDs are expected to be unique within a document. Because the same anchor value is assigned to both elements, the generated markup is invalid HTML. This may affect CSS selectors, JavaScript lookups, HTML validation, and accessibility validation tools.
I expected the custom HTML Anchor to be applied only to the outer
<nav>element. Instead, it is also applied to the inner navigation<ul>.This issue is consistently reproducible with different anchor values and multiple Navigation block instances.
Step-by-step reproduction instructions
header-navigation).<nav>element and the inner<ul class="wp-block-navigation__container">.Screenshots, screen recording, code snippet
Rendered HTML:
The custom HTML Anchor (
header-navigation) is rendered on both the outer<nav>element and the inner navigation<ul>, resulting in duplicate IDs.Browser console:
Environment info
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.